[pypy-issue] Issue #1982: ctypes.Structure subclasses munge `_names` attribute (pypy/pypy)

Ben Longbons issues-reply at bitbucket.org
Fri Feb 13 09:24:02 CET 2015


New issue 1982: ctypes.Structure subclasses munge `_names` attribute
https://bitbucket.org/pypy/pypy/issue/1982/ctypesstructure-subclasses-munge-_names

Ben Longbons:

The below code will print `{}` in python 2.7, 3.2, and 3.4, but `['foo', 'bar']` in pypy 2.4.0 (in python2 or python3 mode).

If there is a reason to introduce new names, they should follow the ctypes `_sunder_` method.

(yeah, yeah, I should use `cffi`)

```
#!python
import ctypes

class Stuff(ctypes.Structure):
    __slots__ = ()
    _fields_ = [('foo', ctypes.c_int), ('bar', ctypes.c_int)]
    _names = {}

print(Stuff._names)
```





More information about the pypy-issue mailing list