@@ -296,36 +296,32 @@ static double augment_Long_AsDouble(HPyContext *ctx, HPy h) {
296296}
297297
298298static HPy augment_Long_FromLong (HPyContext * ctx , long l ) {
299- int32_t i = (int32_t ) l ;
300- if (l == i ) {
301- return toPtr (boxInt (i ));
299+ if (isBoxableInt (l )) {
300+ return toPtr (boxInt ((int32_t ) l ));
302301 } else {
303302 return original_Long_FromLong (ctx , l );
304303 }
305304}
306305
307306static HPy augment_Long_FromUnsignedLong (HPyContext * ctx , unsigned long l ) {
308- int32_t i = (int32_t ) l ;
309- if (l == i ) {
310- return toPtr (boxInt (i ));
307+ if (isBoxableUnsignedInt (l )) {
308+ return toPtr (boxInt ((int32_t ) l ));
311309 } else {
312310 return original_Long_FromUnsignedLong (ctx , l );
313311 }
314312}
315313
316314static HPy augment_Long_FromLongLong (HPyContext * ctx , long long l ) {
317- int32_t i = (int32_t ) l ;
318- if (l == i ) {
319- return toPtr (boxInt (i ));
315+ if (isBoxableInt (l )) {
316+ return toPtr (boxInt ((int32_t ) l ));
320317 } else {
321318 return original_Long_FromLongLong (ctx , l );
322319 }
323320}
324321
325322static HPy augment_Long_FromUnsignedLongLong (HPyContext * ctx , unsigned long long l ) {
326- int32_t i = (int32_t ) l ;
327- if (l == i ) {
328- return toPtr (boxInt (i ));
323+ if (isBoxableUnsignedInt (l )) {
324+ return toPtr (boxInt ((int32_t ) l ));
329325 } else {
330326 return original_Long_FromUnsignedLongLong (ctx , l );
331327 }
0 commit comments