This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: ctypes Structure allows recursive definition
Type: Stage:
Components: Library (Lib) Versions: Python 2.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: theller Nosy List: kermode, theller
Priority: normal Keywords:

Created on 2006-11-17 21:26 by kermode, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg30582 - (view) Author: Lenard Lindstrom (kermode) Date: 2006-11-17 21:26
Ctypes version 1.0.1 and Python 2.4:

A Partially declared structure can be used as a type
in its own field declarations:

Python 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32 bit (Intel)] 
on win32
Type "help", "copyright", "credits" or "license" for more 
information.
>>> from ctypes import Structure, c_int, sizeof, __version__
>>> __version__
'1.0.1'
>>> class S(Structure):
...     pass
...
>>> S._fields_ = [('i', c_int), ('s', S)]
>>> sizeof(S)
4
>>> o=S(7)
>>> o.s.i=12
>>> o.s.s.i=20
>>> o.i
7
>>> o.s.i
12
>>> o.s.s.i
20
>>> sizeof(o)
4
msg30583 - (view) Author: Thomas Heller (theller) * (Python committer) Date: 2006-11-24 19:04
Fixed now in SVN, rev 52841 (trunk) and rev 52842 (release25-maint).
Thanks for the report.
History
Date User Action Args
2022-04-11 14:56:21adminsetgithub: 44249
2006-11-17 21:26:42kermodecreate