File tree Expand file tree Collapse file tree 5 files changed +10
-21
lines changed
Expand file tree Collapse file tree 5 files changed +10
-21
lines changed Original file line number Diff line number Diff line change @@ -335,7 +335,7 @@ struct _is {
335335 The integers that are preallocated are those in the range
336336 -_PY_NSMALLNEGINTS (inclusive) to _PY_NSMALLPOSINTS (not inclusive).
337337 */
338- PyLongObject * small_ints [_PY_NSMALLNEGINTS + _PY_NSMALLPOSINTS ];
338+ PyLongObject small_ints [_PY_NSMALLNEGINTS + _PY_NSMALLPOSINTS ];
339339 struct _Py_bytes_state bytes ;
340340 struct _Py_unicode_state unicode ;
341341 struct _Py_float_state float_state ;
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ static inline PyObject* __PyLong_GetSmallInt_internal(int value)
1717 PyInterpreterState * interp = _PyInterpreterState_GET ();
1818 assert (- _PY_NSMALLNEGINTS <= value && value < _PY_NSMALLPOSINTS );
1919 size_t index = _PY_NSMALLNEGINTS + value ;
20- PyObject * obj = (PyObject * )interp -> small_ints [index ];
20+ PyObject * obj = (PyObject * )& interp -> small_ints [index ];
2121 // _PyLong_GetZero(), _PyLong_GetOne() and get_small_int() must not be
2222 // called before _PyLong_Init() nor after _PyLong_Fini().
2323 assert (obj != NULL );
Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ extern PyStatus _PyUnicode_Init(PyInterpreterState *interp);
5353extern PyStatus _PyUnicode_InitTypes (void );
5454extern PyStatus _PyBytes_Init (PyInterpreterState * interp );
5555extern int _PyStructSequence_Init (void );
56- extern int _PyLong_Init (PyInterpreterState * interp );
56+ extern void _PyLong_Init (PyInterpreterState * interp );
5757extern int _PyLong_InitTypes (void );
5858extern PyStatus _PyTuple_Init (PyInterpreterState * interp );
5959extern PyStatus _PyFaulthandler_Init (int enable );
Original file line number Diff line number Diff line change @@ -5827,24 +5827,17 @@ PyLong_GetInfo(void)
58275827 return int_info ;
58285828}
58295829
5830- int
5830+ void
58315831_PyLong_Init (PyInterpreterState * interp )
58325832{
58335833 for (Py_ssize_t i = 0 ; i < NSMALLNEGINTS + NSMALLPOSINTS ; i ++ ) {
58345834 sdigit ival = (sdigit )i - NSMALLNEGINTS ;
58355835 int size = (ival < 0 ) ? -1 : ((ival == 0 ) ? 0 : 1 );
5836-
5837- PyLongObject * v = _PyLong_New (1 );
5838- if (!v ) {
5839- return -1 ;
5840- }
5841-
5842- Py_SET_SIZE (v , size );
5843- v -> ob_digit [0 ] = (digit )abs (ival );
5844-
5845- interp -> small_ints [i ] = v ;
5836+ interp -> small_ints [i ].ob_base .ob_base .ob_refcnt = 1 ;
5837+ interp -> small_ints [i ].ob_base .ob_base .ob_type = & PyLong_Type ;
5838+ interp -> small_ints [i ].ob_base .ob_size = size ;
5839+ interp -> small_ints [i ].ob_digit [0 ] = (digit )abs (ival );
58465840 }
5847- return 0 ;
58485841}
58495842
58505843
@@ -5863,7 +5856,5 @@ _PyLong_InitTypes(void)
58635856void
58645857_PyLong_Fini (PyInterpreterState * interp )
58655858{
5866- for (Py_ssize_t i = 0 ; i < NSMALLNEGINTS + NSMALLPOSINTS ; i ++ ) {
5867- Py_CLEAR (interp -> small_ints [i ]);
5868- }
5859+ (void )interp ;
58695860}
Original file line number Diff line number Diff line change @@ -659,9 +659,7 @@ pycore_init_singletons(PyInterpreterState *interp)
659659{
660660 PyStatus status ;
661661
662- if (_PyLong_Init (interp ) < 0 ) {
663- return _PyStatus_ERR ("can't init longs" );
664- }
662+ _PyLong_Init (interp );
665663
666664 if (_Py_IsMainInterpreter (interp )) {
667665 _PyFloat_Init ();
You can’t perform that action at this time.
0 commit comments