We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 09044dd commit 19cbe69Copy full SHA for 19cbe69
1 file changed
Objects/longobject.c
@@ -344,8 +344,6 @@ medium_from_stwodigits(stwodigits x)
344
}
345
346
347
-/* If a freshly-allocated int is already shared, it must
348
- be a small integer, so negating it must go to PyLong_FromLong */
349
Py_LOCAL_INLINE(void)
350
_PyLong_Negate(PyLongObject **x_p)
351
{
@@ -357,8 +355,10 @@ _PyLong_Negate(PyLongObject **x_p)
357
355
return;
358
356
359
360
- *x_p = _PyLong_FromSTwoDigits(-medium_value(x));
361
- Py_DECREF(x);
+ /* If a freshly-allocated int is already shared, it must
+ be a small integer, so negating it will fit a single digit */
+ assert(_long_is_small_int((PyObject *)x));
+ *x_p = (PyLongObject *)_PyLong_FromSTwoDigits(-medium_value(x));
362
363
364
#define PYLONG_FROM_INT(UINT_TYPE, INT_TYPE, ival) \
0 commit comments