Attribute getters and setters have wrong arglists.

Bug #508567 reported by yak
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
PyBindGen
Fix Released
Low
Unassigned

Bug Description

The attribute getter and setter functions used in array pointed by tp_getset field of the type structure have incorrect prototypes. For instance attributes, they are missing the "void *closure" argument. For static attributes, they miss even more (getter has no args at all).

These functions have a fixed prototypes defined by the "getter" and "setter" typedefs, as can be seen here:
http://docs.python.org/c-api/typeobj.html#tp_getset

Compiler misses this because the function pointers are cast to the mentioned typedefs.

Depending on a calling convention used by various compilers, this may or may not cause problems but it's definitely a bug.

Related branches

Revision history for this message
Gustavo Carneiro (gjc) wrote :

I am pretty sure in C language you can safely implement a function that takes fewer arguments than expected, regardless of compiler. But just to make you happy, I added the missing parameters...

Changed in pybindgen:
importance: Undecided → Low
status: New → Fix Committed
Revision history for this message
yak (yak) wrote :

Thanks for the fix.

This depends on the calling convention. It's true that C prefers a convention where the caller is responsible for clearing the stack. Otherwise functions like printf() wouldn't be possible. But there are conventions forcing the callee to do the cleanup and in such case, calling the function with arglist of different size will cause problems. That's why I think the arglists should stay consistent if there's no real reason for not making them so.

I found this while trying to force pybindgen to generate code for Nokia's Python for S60 so I could wrap some Symbian C++ classes with it. I had the situation where the code would work on the S60 emulator but fail on the phone (some unexpected behavior while reading an instance attribute). I'm not sure if this was the cause but it was one of the few things I changed before it started working. I'm also not sure which calling convention is used on Symbian/GCCE.

Gustavo Carneiro (gjc)
Changed in pybindgen:
status: Fix Committed → Fix Released
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.