@@ -6800,58 +6800,62 @@ PyObject* PyLong_FromUInt64(uint64_t value)
68006800 PYLONG_FROM_UINT (uint64_t , value );
68016801}
68026802
6803- #define LONG_TO_INT (obj , value , type_name ) \
6803+ #define LONG_TO_INT (type , obj , result ) \
68046804 do { \
6805+ type value; \
68056806 int flags = (Py_ASNATIVEBYTES_NATIVE_ENDIAN \
68066807 | Py_ASNATIVEBYTES_ALLOW_INDEX); \
6807- Py_ssize_t bytes = PyLong_AsNativeBytes(obj, value, sizeof(* value), flags); \
6808+ Py_ssize_t bytes = PyLong_AsNativeBytes(obj, & value, sizeof(value), flags); \
68086809 if (bytes < 0) { \
68096810 return -1; \
68106811 } \
6811- if ((size_t)bytes > sizeof(* value)) { \
6812+ if ((size_t)bytes > sizeof(value)) { \
68126813 PyErr_SetString(PyExc_OverflowError, \
6813- "Python int too large to convert to " type_name ); \
6814+ "Python int too large to convert to C " #type ); \
68146815 return -1; \
68156816 } \
6817+ *result = value; \
68166818 return 0; \
68176819 } while (0)
68186820
6819- int PyLong_AsInt32 (PyObject * obj , int32_t * value )
6821+ int PyLong_AsInt32 (PyObject * obj , int32_t * result )
68206822{
6821- LONG_TO_INT (obj , value , "C int32_t" );
6823+ LONG_TO_INT (int32_t , obj , result );
68226824}
68236825
6824- int PyLong_AsInt64 (PyObject * obj , int64_t * value )
6826+ int PyLong_AsInt64 (PyObject * obj , int64_t * result )
68256827{
6826- LONG_TO_INT (obj , value , "C int64_t" );
6828+ LONG_TO_INT (int64_t , obj , result );
68276829}
68286830
6829- #define LONG_TO_UINT (obj , value , type_name ) \
6831+ #define LONG_TO_UINT (type , obj , result ) \
68306832 do { \
6833+ type value; \
68316834 int flags = (Py_ASNATIVEBYTES_NATIVE_ENDIAN \
68326835 | Py_ASNATIVEBYTES_UNSIGNED_BUFFER \
68336836 | Py_ASNATIVEBYTES_REJECT_NEGATIVE \
68346837 | Py_ASNATIVEBYTES_ALLOW_INDEX); \
6835- Py_ssize_t bytes = PyLong_AsNativeBytes(obj, value, sizeof(* value), flags); \
6838+ Py_ssize_t bytes = PyLong_AsNativeBytes(obj, & value, sizeof(value), flags); \
68366839 if (bytes < 0) { \
68376840 return -1; \
68386841 } \
6839- if ((size_t)bytes > sizeof(* value)) { \
6842+ if ((size_t)bytes > sizeof(value)) { \
68406843 PyErr_SetString(PyExc_OverflowError, \
6841- "Python int too large to convert to " type_name ); \
6844+ "Python int too large to convert to C " #type ); \
68426845 return -1; \
68436846 } \
6847+ *result = value; \
68446848 return 0; \
68456849 } while (0)
68466850
6847- int PyLong_AsUInt32 (PyObject * obj , uint32_t * value )
6851+ int PyLong_AsUInt32 (PyObject * obj , uint32_t * result )
68486852{
6849- LONG_TO_UINT (obj , value , "C uint32_t" );
6853+ LONG_TO_UINT (uint32_t , obj , result );
68506854}
68516855
6852- int PyLong_AsUInt64 (PyObject * obj , uint64_t * value )
6856+ int PyLong_AsUInt64 (PyObject * obj , uint64_t * result )
68536857{
6854- LONG_TO_UINT (obj , value , "C uint64_t" );
6858+ LONG_TO_UINT (uint64_t , obj , result );
68556859}
68566860
68576861
0 commit comments