Skip to content

Commit d64273e

Browse files
committed
Fix Int32 conversion for Python 3.
1 parent 95638e5 commit d64273e

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/runtime/converter.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,7 @@ static bool ToPrimitive(IntPtr value, Type obType, out Object result,
405405
return true;
406406

407407
case TypeCode.Int32:
408+
#if !(PYTHON32 || PYTHON33 || PYTHON34)
408409
// Trickery to support 64-bit platforms.
409410
if (IntPtr.Size == 4) {
410411
op = Runtime.PyNumber_Int(value);
@@ -427,6 +428,10 @@ static bool ToPrimitive(IntPtr value, Type obType, out Object result,
427428
return true;
428429
}
429430
else {
431+
#else
432+
// When using Python3 always use the PyLong API
433+
{
434+
#endif
430435
op = Runtime.PyNumber_Long(value);
431436
if (op == IntPtr.Zero) {
432437
if (Exceptions.ExceptionMatches(overflow)) {

0 commit comments

Comments
 (0)