@@ -228,7 +228,7 @@ static inline Py_ssize_t
228228_PyLong_DigitCount (const PyLongObject * op )
229229{
230230 assert (PyLong_Check (op ));
231- return op -> long_value .lv_tag >> NON_SIZE_BITS ;
231+ return ( Py_ssize_t )( op -> long_value .lv_tag >> NON_SIZE_BITS ) ;
232232}
233233
234234/* Equivalent to _PyLong_DigitCount(op) * _PyLong_NonCompactSign(op) */
@@ -263,15 +263,16 @@ _PyLong_SameSign(const PyLongObject *a, const PyLongObject *b)
263263 return (a -> long_value .lv_tag & SIGN_MASK ) == (b -> long_value .lv_tag & SIGN_MASK );
264264}
265265
266- #define TAG_FROM_SIGN_AND_SIZE (sign , size ) ((1 - (sign)) | ((size) << NON_SIZE_BITS))
266+ #define TAG_FROM_SIGN_AND_SIZE (sign , size ) \
267+ ((uintptr_t)(1 - (sign)) | ((uintptr_t)(size) << NON_SIZE_BITS))
267268
268269static inline void
269270_PyLong_SetSignAndDigitCount (PyLongObject * op , int sign , Py_ssize_t size )
270271{
271272 assert (size >= 0 );
272273 assert (-1 <= sign && sign <= 1 );
273274 assert (sign != 0 || size == 0 );
274- op -> long_value .lv_tag = TAG_FROM_SIGN_AND_SIZE (sign , ( size_t ) size );
275+ op -> long_value .lv_tag = TAG_FROM_SIGN_AND_SIZE (sign , size );
275276}
276277
277278static inline void
@@ -281,7 +282,7 @@ _PyLong_SetDigitCount(PyLongObject *op, Py_ssize_t size)
281282 op -> long_value .lv_tag = (((size_t )size ) << NON_SIZE_BITS ) | (op -> long_value .lv_tag & SIGN_MASK );
282283}
283284
284- #define NON_SIZE_MASK ~((1 << NON_SIZE_BITS) - 1)
285+ #define NON_SIZE_MASK ~(uintptr_t)( (1 << NON_SIZE_BITS) - 1)
285286
286287static inline void
287288_PyLong_FlipSign (PyLongObject * op ) {
0 commit comments