Py_BuildValue("I", ...) does not work

Nick Craig-Wood nick at craig-wood.com
Mon Aug 21 08:30:03 EDT 2006


Martin Kulas <coolazNOSPAM at web.de> wrote:
>  I have a problem with Py_BuildValue: I want to convert an unsigned int
>  to a PyObject *.
>  http://docs.python.org/api/arg-parsing.html says that I can use
>  "I" as a format string.
>  But it does not work :-\

I tried your examples under linux.

It fails under python 2.3 in the same fashion as you noted, but works
under 2.4.

On my system (debian/testing) I have python 2.4.4c0 installed.

Handling of these sized integers > 0x80000000 changed from 2.3 to 2.4
so maybe this was a fixed bug?

I can't seem to find the point release changelogs though!

    $ python2.3 setup.py build
    $ cd build/lib.linux-i686-2.3/
    $ python2.3
    Python 2.3.5 (#2, Jun 13 2006, 23:12:55) 
    [GCC 4.1.2 20060613 (prerelease) (Debian 4.1.1-4)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import mini
    >>> mini.foo()
    Traceback (most recent call last):
      File "<stdin>", line 1, in ?
    SystemError: bad format char passed to Py_BuildValue
    >>> 


    $ python2.4 setup.py build
    $ cd build/lib.linux-i686-2.4 
    $ python2.4
    Python 2.4.4c0 (#2, Jun 14 2006, 22:35:41) 
    [GCC 4.1.2 20060613 (prerelease) (Debian 4.1.1-4)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import mini
    >>> mini.foo()
    3735928495L
    >>> 

-- 
Nick Craig-Wood <nick at craig-wood.com> -- http://www.craig-wood.com/nick



More information about the Python-list mailing list