Skip to content

Commit

Permalink
Correct types
Browse files Browse the repository at this point in the history
  • Loading branch information
srinivasreddy committed Jan 22, 2025
1 parent ba70518 commit 34315cb
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Objects/longobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,17 @@ maybe_small_long(PyLongObject *v)

#define PYLONG_FROM_SIGNED(INT_TYPE, ival) \
do { \
unsigned long abs_ival, t; \
if (IS_SMALL_INT(ival)) { \
return get_small_int((sdigit)(ival)); \
} \
if (-(INT_TYPE)PyLong_MASK <= (ival) && (ival) <= (INT_TYPE)PyLong_MASK) { \
return _PyLong_FromMedium((sdigit)(ival)); \
} \
/* Count digits (at least two - smaller cases were handled above). */ \
INT_TYPE abs_ival = (ival) < 0 ? 0U-(INT_TYPE)(ival) : (INT_TYPE)(ival); \
abs_ival = (ival) < 0 ? 0U-(unsigned long)(ival) : (unsigned long)(ival); \
/* Do shift in two steps to avoid possible undefined behavior. */ \
INT_TYPE t = abs_ival >> PyLong_SHIFT >> PyLong_SHIFT; \
t = abs_ival >> PyLong_SHIFT >> PyLong_SHIFT; \
Py_ssize_t ndigits = 2; \
while (t) { \
++ndigits; \
Expand Down

0 comments on commit 34315cb

Please sign in to comment.