File tree 3 files changed +20
-2
lines changed
3 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -691,6 +691,8 @@ PyAPI_DATA(PyObject) _Py_NotImplementedStruct; /* Don't use this directly */
691
691
/* Macro for returning Py_NotImplemented from a function */
692
692
#define Py_RETURN_NOTIMPLEMENTED return Py_NewRef(Py_NotImplemented)
693
693
694
+ extern Py_ssize_t _PyHASH_NONE ;
695
+
694
696
/* Rich comparison opcodes */
695
697
#define Py_LT 0
696
698
#define Py_LE 1
Original file line number Diff line number Diff line change @@ -1638,6 +1638,16 @@ none_bool(PyObject *v)
1638
1638
return 0 ;
1639
1639
}
1640
1640
1641
+ Py_ssize_t _PyHASH_NONE ;
1642
+
1643
+ static Py_hash_t none_hash (PyObject * v )
1644
+ {
1645
+ #ifdef Py_DEBUG
1646
+ assert (_Py_HashSecret_Initialized );
1647
+ #endif
1648
+ return _PyHASH_NONE ;
1649
+ }
1650
+
1641
1651
static PyNumberMethods none_as_number = {
1642
1652
0 , /* nb_add */
1643
1653
0 , /* nb_subtract */
@@ -1689,7 +1699,7 @@ PyTypeObject _PyNone_Type = {
1689
1699
& none_as_number , /*tp_as_number*/
1690
1700
0 , /*tp_as_sequence*/
1691
1701
0 , /*tp_as_mapping*/
1692
- 0 , /* tp_hash */
1702
+ ( hashfunc ) none_hash , /* tp_hash */
1693
1703
0 , /*tp_call */
1694
1704
0 , /*tp_str */
1695
1705
0 , /*tp_getattro */
Original file line number Diff line number Diff line change @@ -543,6 +543,11 @@ _PyOS_URandomNonblock(void *buffer, Py_ssize_t size)
543
543
return pyurandom (buffer , size , 0 , 1 );
544
544
}
545
545
546
+ void
547
D6B4
+ _Py_InitNoneHash () {
548
+ const unsigned char data [] = {0xFC , 0xA8 , 0x64 , 0x20 };
549
+ _PyHASH_NONE = _Py_HashBytes (data , sizeof (data ));
550
+ }
546
551
547
552
PyStatus
548
553
_Py_HashRandomization_Init (const PyConfig * config )
@@ -576,14 +581,15 @@ _Py_HashRandomization_Init(const PyConfig *config)
576
581
pyurandom() is non-blocking mode (blocking=0): see the PEP 524. */
577
582
res = pyurandom (secret , secret_size , 0 , 0 );
578
583
if (res < 0 ) {
584
+ _Py_HashSecret_Initialized = 0 ;
579
585
return _PyStatus_ERR ("failed to get random numbers "
580
586
"to initialize Python" );
581
587
}
582
588
}
589
+ _Py_InitNoneHash ();
583
590
return _PyStatus_OK ();
584
591
}
585
592
586
-
587
593
void
588
594
_Py_HashRandomization_Fini (void )
589
595
{
You can’t perform that action at this time.
0 commit comments