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.

Author meador.inge
Recipients meador.inge, techtonik, vstinner
Date 2012-11-28.01:02:35
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1354064556.54.0.215089075596.issue16566@psf.upfronthosting.co.za>
In-reply-to
Content
A string *is* a sequence.  That is actually part of the problem.
Consider a slight variation on the original repro case:

>>> class _OFFSET(Structure):
...     _fields_ = [
...         ('Offset', c_int),
...         ('OffsetHigh', c_int)]
... 
[70412 refs]
>>> class _OFFSET_UNION(Union):
...     _anonymous_ = 12
...     _fields_ = [
...         ('_offset', _OFFSET),
...         ('Pointer', c_int)]
... 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: _anonymous_ must be a sequence

As expected, a TypeError is produced.

Now consider the original error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: type object '_OFFSET_UNION' has no attribute '_'

This happens because the string sequence '_offset' is iterated and the
first item in the iteration is '_', which isn't a field of _OFFSET_UNION.

So, the error checking is already there (in the form of PySequence_Fast)
and is consistent with the documentation.  This should be closed.
History
Date User Action Args
2012-11-28 01:02:36meador.ingesetrecipients: + meador.inge, vstinner, techtonik
2012-11-28 01:02:36meador.ingesetmessageid: <1354064556.54.0.215089075596.issue16566@psf.upfronthosting.co.za>
2012-11-28 01:02:36meador.ingelinkissue16566 messages
2012-11-28 01:02:35meador.ingecreate