From: Tim Peters Date: Sat, 2 Mar 2002 04:18:04 +0000 (+0000) Subject: _PyLong_Copy(): was creating a copy of the absolute value, but should X-Git-Tag: v2.3c1~6594 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5329cdb3cea9f76a8b758aa61058455a5bfb4506;p=python _PyLong_Copy(): was creating a copy of the absolute value, but should copy the sign too. Added a test to test_descr to ensure that it does. Bugfix candidate. --- diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py index e667efb18a..de9bba1636 100644 --- a/Lib/test/test_descr.py +++ b/Lib/test/test_descr.py @@ -1751,6 +1751,7 @@ def inherits(): # Check that negative clones don't segfault a = longclone(-1) vereq(a.__dict__, {}) + vereq(long(a), -1) # verify PyNumber_Long() copies the sign bit class precfloat(float): __slots__ = ['prec'] diff --git a/Objects/longobject.c b/Objects/longobject.c index 5b7a00aa9f..f3e7df7134 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -63,7 +63,7 @@ _PyLong_Copy(PyLongObject *src) i = -(i); result = _PyLong_New(i); if (result != NULL) { - result->ob_size = i; + result->ob_size = src->ob_size; while (--i >= 0) result->ob_digit[i] = src->ob_digit[i]; }