Skip to content

Commit eb966bf

Browse files
committed
sync with CPython pr
1 parent cc05a9a commit eb966bf

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

pythoncapi_compat.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1789,6 +1789,7 @@ static inline int
17891789
PyLong_Export(PyObject *obj, PyLongExport *export_long)
17901790
{
17911791
if (!PyLong_Check(obj)) {
1792+
memset(export_long, 0, sizeof(*export_long));
17921793
PyErr_Format(PyExc_TypeError, "expected int, got %s",
17931794
Py_TYPE(obj)->tp_name);
17941795
return -1;
@@ -1841,7 +1842,7 @@ PyLong_FreeExport(PyLongExport *export_long)
18411842
static inline PyLongWriter*
18421843
PyLongWriter_Create(int negative, Py_ssize_t ndigits, void **digits)
18431844
{
1844-
if (ndigits < 0) {
1845+
if (ndigits <= 0) {
18451846
PyErr_SetString(PyExc_ValueError, "ndigits must be positive");
18461847
return NULL;
18471848
}
@@ -1851,9 +1852,6 @@ PyLongWriter_Create(int negative, Py_ssize_t ndigits, void **digits)
18511852
if (obj == NULL) {
18521853
return NULL;
18531854
}
1854-
if (ndigits == 0) {
1855-
assert(_PyLong_GetDigits(obj)[0] == 0);
1856-
}
18571855
_PyLong_SetSignAndDigitCount(obj, negative?-1:1, ndigits);
18581856

18591857
*digits = _PyLong_GetDigits(obj);

0 commit comments

Comments
 (0)