__len__binding don't work in 0.17.x versions

Bug #1443379 reported by joris.vaillant@gmail.com
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
PyBindGen
New
Undecided
Unassigned

Bug Description

Binding of the __len__ function don't work anymore in pybindgen version >= 0.17.x when used with python2.7.

If I want to bind the __len__ method with a line looking like this:

mb.add_method('size', retval('int'), [], is_const=True, custom_name='__len__')
(full code available there: https://github.com/jorisv/Eigen3ToPython/blob/master/src/generate.py#L61)

The following code will fail:

```
import eigen3
a = eigen3.Vector3d()
len(a)
---------------------------------------------------------------------------
SystemError Traceback (most recent call last)
<ipython-input-3-af8c77e09569> in <module>()
----> 1 len(a)

SystemError: ../Objects/longobject.c:371: bad argument to internal function
```

Applying the joint patch fix the issue by forcing the use of PyLong_asSsize_t in python3 and PyInt_asSsize_t in python2.

Tags: len python2
Revision history for this message
joris.vaillant@gmail.com (joris-vaillant) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.