Skip to content

Commit d335b11

Browse files
committed
use the PYLONG_FROM_*INT macros in more
PyLong_From* functions
1 parent ec46a55 commit d335b11

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

Objects/longobject.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6741,17 +6741,21 @@ PyUnstable_Long_CompactValue(const PyLongObject* op) {
67416741
}
67426742

67436743

6744-
PyObject* PyLong_FromInt32(int32_t value)
6745-
{ return PyLong_FromNativeBytes(&value, sizeof(value), -1); }
6744+
PyObject* PyLong_FromInt32(int32_t value) {
6745+
PYLONG_FROM_INT(uint32_t, int32_t, value);
6746+
}
67466747

6747-
PyObject* PyLong_FromUInt32(uint32_t value)
6748-
{ return PyLong_FromUnsignedNativeBytes(&value, sizeof(value), -1); }
6748+
PyObject* PyLong_FromUInt32(uint32_t value) {
6749+
PYLONG_FROM_UINT(uint32_t, value);
6750+
}
67496751

6750-
PyObject* PyLong_FromInt64(int64_t value)
6751-
{ return PyLong_FromNativeBytes(&value, sizeof(value), -1); }
6752+
PyObject* PyLong_FromInt64(int64_t value) {
6753+
PYLONG_FROM_INT(uint64_t, int64_t, value);
6754+
}
67526755

6753-
PyObject* PyLong_FromUInt64(uint64_t value)
6754-
{ return PyLong_FromUnsignedNativeBytes(&value, sizeof(value), -1); }
6756+
PyObject* PyLong_FromUInt64(uint64_t value) {
6757+
PYLONG_FROM_UINT(uint64_t, value);
6758+
}
67556759

67566760
#define LONG_TO_INT(obj, value, type_name) \
67576761
do { \

0 commit comments

Comments
 (0)