diff options
author | Alec Cooper <ahnolds@gmail.com> | 2016-01-24 19:18:00 -0500 |
---|---|---|
committer | Alec Cooper <ahnolds@gmail.com> | 2016-02-04 15:27:54 -0500 |
commit | 2e1595a4d07eaa3434f7e1a451bcf01cfad6f0e1 (patch) | |
tree | 1657dd2329d93d9cd1cd4d438023c0587c5bc14f /Lib | |
parent | 8dcbbe8b6c6f74c03b4cd4a38790e161767f6cad (diff) | |
download | swig-2e1595a4d07eaa3434f7e1a451bcf01cfad6f0e1.tar.gz |
When possible, use PyInt rather than PyLong
This is especially important for the unsigned long typemap, which is used by
the size_t typemap, which is in turn used for lengths of std containers etc.
In Python2, len requires old-style classes' __len__ method return a PyIntObject
rather than a PyLongObject, so this supports that requirement.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/python/pyprimtypes.swg | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Lib/python/pyprimtypes.swg b/Lib/python/pyprimtypes.swg index 2ef09a1ba..fb5bbf6df 100644 --- a/Lib/python/pyprimtypes.swg +++ b/Lib/python/pyprimtypes.swg @@ -67,7 +67,7 @@ SWIGINTERNINLINE PyObject* /* long */ %fragment(SWIG_From_frag(long),"header") { - %define_as(SWIG_From_dec(long), PyLong_FromLong) + %define_as(SWIG_From_dec(long), PyInt_FromLong) } %fragment(SWIG_AsVal_frag(long),"header", @@ -123,7 +123,7 @@ SWIGINTERNINLINE PyObject* SWIG_From_dec(unsigned long)(unsigned long value) { return (value > LONG_MAX) ? - PyLong_FromUnsignedLong(value) : PyLong_FromLong(%numeric_cast(value,long)); + PyLong_FromUnsignedLong(value) : PyInt_FromLong(%numeric_cast(value,long)); } } @@ -186,7 +186,7 @@ SWIGINTERNINLINE PyObject* SWIG_From_dec(long long)(long long value) { return ((value < LONG_MIN) || (value > LONG_MAX)) ? - PyLong_FromLongLong(value) : PyLong_FromLong(%numeric_cast(value,long)); + PyLong_FromLongLong(value) : PyInt_FromLong(%numeric_cast(value,long)); } %#endif } @@ -244,7 +244,7 @@ SWIGINTERNINLINE PyObject* SWIG_From_dec(unsigned long long)(unsigned long long value) { return (value > LONG_MAX) ? - PyLong_FromUnsignedLongLong(value) : PyLong_FromLong(%numeric_cast(value,long)); + PyLong_FromUnsignedLongLong(value) : PyInt_FromLong(%numeric_cast(value,long)); } %#endif } |