Skip to content

Commit d5e1fef

Browse files
committed
+1
1 parent 1b80350 commit d5e1fef

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Objects/longobject.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,12 +217,17 @@ PyObject *
217217
_PyLong_Copy(PyLongObject *src)
218218
{
219219
assert(src != NULL);
220+
int sign;
220221

221222
if (_PyLong_IsCompact(src)) {
222223
stwodigits ival = medium_value(src);
223224
if (IS_SMALL_INT(ival)) {
224225
return get_small_int((sdigit)ival);
225226
}
227+
sign = _PyLong_CompactSign(src);
228+
}
229+
else {
230+
sign = _PyLong_NonCompactSign(src);
226231
}
227232

228233
Py_ssize_t size = _PyLong_DigitCount(src);
@@ -232,8 +237,9 @@ _PyLong_Copy(PyLongObject *src)
232237
PyErr_NoMemory();
233238
return NULL;
234239
}
235-
_PyLong_SetSignAndDigitCount(result, _PyLong_Sign(src), size);
236-
memcpy(result->long_value.ob_digit, src->long_value.ob_digit, size * sizeof(digit));
240+
_PyLong_SetSignAndDigitCount(result, sign, size);
241+
memcpy(result->long_value.ob_digit, src->long_value.ob_digit,
242+
size * sizeof(digit));
237243
return (PyObject *)result;
238244
}
239245

0 commit comments

Comments
 (0)