Skip to content

Commit

Permalink
+ use PyLong_AsLongAndOverflow in pythoncapi_compat.h
Browse files Browse the repository at this point in the history
  • Loading branch information
skirpichev committed Sep 18, 2024
1 parent b5afa75 commit 3ed45cc
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/pythoncapi_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -1265,10 +1265,10 @@ PyLong_Export(PyObject *obj, PyLongExport *export_long)
}
PyLongObject *self = (PyLongObject*)obj;

int64_t value;
Py_ssize_t bytes = PyLong_AsNativeBytes(self, &value, sizeof(value), -1);
int overflow;
long value = PyLong_AsLongAndOverflow(obj, &overflow);

if ((size_t)bytes <= sizeof(value)) {
if (!overflow) {
export_long->value = value;
export_long->negative = 0;
export_long->ndigits = 0;
Expand Down

0 comments on commit 3ed45cc

Please sign in to comment.