Meador Inge added the comment:
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.
----------
nosy: +meador.inge
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue16566>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com