[pypy-issue] [issue1473] Unexpected behavior when inheriting from a ctypes.Structure

Michael Dale Long tracker at bugs.pypy.org
Sat May 4 04:19:48 CEST 2013


New submission from Michael Dale Long <nikarul at yahoo.com>:

I have some code that relies on inheriting from SDL's SDL_Rect class.  This
works in CPython 2.x and 3.x, but fails in PyPy 2.0 beta and the most recent
nightly build as well.  There seems to be some problem passing arguments to the
superclass constructor.  See the attached sdl_inherit_test.py for a simplified
example (SDL libraries not required, it just declares the Structure), and
output.txt for my tests with various Python interpreters on Gentoo Linux.

----------
nosy: +link
status: unread -> chatting

________________________________________
PyPy bug tracker <tracker at bugs.pypy.org>
<https://bugs.pypy.org/issue1473>
________________________________________
-------------- next part --------------
link at brinstar /work $ python3 --version
Python 3.2.4

link at brinstar /work $ python3 ./sdl_inherit_test.py 
SDL_Rect:  0 0 10 10
Our_Rect:  5 5 15 15

link at brinstar /work $ python2 --version
Python 2.7.3

link at brinstar /work $ python2 ./sdl_inherit_test.py 
SDL_Rect:  0 0 10 10
Our_Rect:  5 5 15 15

link at brinstar /work $ pypy-c2.0 --version
Python 2.7.3 (07e08e9c885ca67d89bcc304e45a32346daea2fa, Apr 03 2013, 12:48:25)
[PyPy 2.0.0-beta1]
link at brinstar /work $ pypy-c2.0 ./sdl_inherit_test.py 
Traceback (most recent call last):
  File "app_main.py", line 52, in run_toplevel
  File "./sdl_inherit_test.py", line 24, in <module>
    subrect = Our_Rect(5, 5, 15, 15)
  File "./sdl_inherit_test.py", line 16, in __init__
    SDL_Rect.__init__(self, args[0], args[1], args[2], args[3])
  File "/usr/lib64/pypy2.0/lib_pypy/_ctypes/structure.py", line 228, in __init__
    raise TypeError("too many initializers")
TypeError: too many initializers

link at brinstar /work $ ./pypy-c-jit-63819-c16cd00e82ef-linux64/bin/pypy --version
./pypy-c-jit-63819-c16cd00e82ef-linux64/bin/pypy: /usr/lib64/libssl.so.1.0.0: no version information available (required by ./pypy-c-jit-63819-c16cd00e82ef-linux64/bin/pypy)
./pypy-c-jit-63819-c16cd00e82ef-linux64/bin/pypy: /usr/lib64/libcrypto.so.1.0.0: no version information available (required by ./pypy-c-jit-63819-c16cd00e82ef-linux64/bin/pypy)
Python 2.7.3 (c16cd00e82ef, May 03 2013, 22:00:19)
[PyPy 2.0.0-beta2 with GCC 4.6.3]

link at brinstar /work $ ./pypy-c-jit-63819-c16cd00e82ef-linux64/bin/pypy ./sdl_inherit_test.py 
./pypy-c-jit-63819-c16cd00e82ef-linux64/bin/pypy: /usr/lib64/libssl.so.1.0.0: no version information available (required by ./pypy-c-jit-63819-c16cd00e82ef-linux64/bin/pypy)
./pypy-c-jit-63819-c16cd00e82ef-linux64/bin/pypy: /usr/lib64/libcrypto.so.1.0.0: no version information available (required by ./pypy-c-jit-63819-c16cd00e82ef-linux64/bin/pypy)
Traceback (most recent call last):
  File "app_main.py", line 72, in run_toplevel
  File "./sdl_inherit_test.py", line 24, in <module>
    subrect = Our_Rect(5, 5, 15, 15)
  File "./sdl_inherit_test.py", line 16, in __init__
    SDL_Rect.__init__(self, args[0], args[1], args[2], args[3])
  File "/work/pypy-c-jit-63819-c16cd00e82ef-linux64/lib_pypy/_ctypes/structure.py", line 228, in __init__
    raise TypeError("too many initializers")
TypeError: too many initializers


More information about the pypy-issue mailing list