Message176501
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. |
|
Date |
User |
Action |
Args |
2012-11-28 01:02:36 | meador.inge | set | recipients:
+ meador.inge, vstinner, techtonik |
2012-11-28 01:02:36 | meador.inge | set | messageid: <1354064556.54.0.215089075596.issue16566@psf.upfronthosting.co.za> |
2012-11-28 01:02:36 | meador.inge | link | issue16566 messages |
2012-11-28 01:02:35 | meador.inge | create | |
|