Commit 5329cdb3 authored by Tim Peters's avatar Tim Peters

_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.
parent db30ac41
...@@ -1751,6 +1751,7 @@ def inherits(): ...@@ -1751,6 +1751,7 @@ def inherits():
# Check that negative clones don't segfault # Check that negative clones don't segfault
a = longclone(-1) a = longclone(-1)
vereq(a.__dict__, {}) vereq(a.__dict__, {})
vereq(long(a), -1) # verify PyNumber_Long() copies the sign bit
class precfloat(float): class precfloat(float):
__slots__ = ['prec'] __slots__ = ['prec']
......
...@@ -63,7 +63,7 @@ _PyLong_Copy(PyLongObject *src) ...@@ -63,7 +63,7 @@ _PyLong_Copy(PyLongObject *src)
i = -(i); i = -(i);
result = _PyLong_New(i); result = _PyLong_New(i);
if (result != NULL) { if (result != NULL) {
result->ob_size = i; result->ob_size = src->ob_size;
while (--i >= 0) while (--i >= 0)
result->ob_digit[i] = src->ob_digit[i]; result->ob_digit[i] = src->ob_digit[i];
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment