Issue 40 in ctypesgen: Issue with _anonymous_ fields of non-struct types

8 views
Skip to first unread message

codesite...@google.com

unread,
Feb 27, 2013, 10:32:40 PM2/27/13
to ctyp...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 40 by jli...@gmail.com: Issue with _anonymous_ fields of
non-struct types
http://code.google.com/p/ctypesgen/issues/detail?id=40

What steps will reproduce the problem?
1. Checkout software
2. Go into test directory
3. Run "./testsuite.py"

What is the expected output? What do you see instead?

I expect all the tests to pass, instead I get 3 of these errors:

======================================================================
ERROR: test_structures (__main__.StructuresTest)
Tests from structures.py
----------------------------------------------------------------------
Traceback (most recent call last):
File "./testsuite.py", line 220, in setUp
self.module, output = ctypesgentest.test(header_str)
File "/home/jlisee/projects/ctypesgen-read-only/test/ctypesgentest.py",
line 53, in test
reload(module) # import twice, this hack ensure that "temp" is force
loaded (there *must* be a better way to do this)
File "/home/jlisee/projects/ctypesgen-read-only/test/temp.py", line 622,
in <module>
AttributeError: type object 'c_uint' has no attribute '_fields_


What version of the product are you using? On what operating system?

Python 2.7, Ubuntu 12.04 64 bit SVN r147 (with patch from Issue 39)

Please provide any additional information below.

The python docs say
(http://docs.python.org/2/library/ctypes.html#ctypes.Structure._anonymous_):

Say "An optional sequence that lists the names of unnamed (anonymous)
fields. _anonymous_ must be already defined when _fields_ is assigned,
otherwise it will have no effect."

The generated code is:

# /usr/include/x86_64-linux-gnu/bits/waitstatus.h: 70
class struct_anon_21(Structure):
pass

struct_anon_21.__slots__ = [
'__w_termsig',
'__w_coredump',
'__w_retcode',
'unnamed_1',
]

struct_anon_21._anonymous_ = [
'unnamed_1',
]

struct_anon_21._fields_ = [
('__w_termsig', c_uint, 7),
('__w_coredump', c_uint, 1),
('__w_retcode', c_uint, 8),
('unnamed_1', c_int),
]

And the referenced source:

http://repo-genesis3.cbi.utsa.edu/crossref/ns-sli/usr/include/bits/waitstatus.h.html

--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings
Reply all
Reply to author
Forward
0 new messages