@@ -296,36 +296,32 @@ static double augment_Long_AsDouble(HPyContext *ctx, HPy h) {
296
296
}
297
297
298
298
static 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 ));
302
301
} else {
303
302
return original_Long_FromLong (ctx , l );
304
303
}
305
304
}
306
305
307
306
static 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 ));
311
309
} else {
312
310
return original_Long_FromUnsignedLong (ctx , l );
313
311
}
314
312
}
315
313
316
314
static 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 ));
320
317
} else {
321
318
return original_Long_FromLongLong (ctx , l );
322
319
}
323
320
}
324
321
325
322
static 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 ));
329
325
} else {
330
326
return original_Long_FromUnsignedLongLong (ctx , l );
331
327
}
0 commit comments