[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[patch] swig 2.0.5+, python ints vs. longs

From: Peter Samuelson <peter_at_p12n.org>
Date: Sun, 17 Jun 2012 10:23:34 -0500

For reasons I do not understand, swig 2.0.5 and higher has changed
handling of python ints and longs in some way that breaks the Python
testsuite. This fixes it. The testsuite. I don't know if it fixes
the real issue, I have no idea if it's a reasonable approach. I'm not
at all comfortable with swig.

[[[
* subversion/bindings/swig/core.i
  (python typemap: char *buffer, apr_size_t *len): Accept either a
   PyInt or a PyLong buffer length argument. swig 2.0.5+ handles this
   differently to previous releases.
]]]
--- subversion/bindings/swig/core.i
+++ subversion/bindings/swig/core.i
@@ -351,12 +351,17 @@
 */
 #ifdef SWIGPYTHON
 %typemap(in) (char *buffer, apr_size_t *len) ($*2_type temp) {
- if (!PyInt_Check($input)) {
+ if (PyLong_Check($input)) {
+ temp = PyLong_AsLong($input);
+ }
+ else if (PyInt_Check($input)) {
+ temp = PyInt_AsLong($input);
+ }
+ else {
         PyErr_SetString(PyExc_TypeError,
                         "expecting an integer for the buffer size");
         SWIG_fail;
     }
- temp = PyInt_AsLong($input);
     if (temp < 0) {
         PyErr_SetString(PyExc_ValueError,
                         "buffer size must be a positive integer");
Received on 2012-06-17 17:24:14 CEST

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.