[issue16566] Structure._anonymous_ should not allow strings

2014-07-02 Thread Terry J. Reedy
Changes by Terry J. Reedy : -- stage: -> resolved status: open -> closed ___ Python tracker ___ ___ Python-bugs-list mailing list Uns

[issue16566] Structure._anonymous_ should not allow strings

2012-11-30 Thread Terry J. Reedy
Changes by Terry J. Reedy : -- nosy: +terry.reedy versions: -Python 3.1 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsu

[issue16566] Structure._anonymous_ should not allow strings

2012-11-28 Thread Amaury Forgeot d'Arc
Amaury Forgeot d'Arc added the comment: OTOH, __slots__ also allows a single string, but it is silently converted to a 1-tuple: class C: __slots__ = 'abc' assert 'abc' in C.__dict__ -- nosy: +amaury.forgeotdarc status: pending -> open ___ Python

[issue16566] Structure._anonymous_ should not allow strings

2012-11-28 Thread anatoly techtonik
anatoly techtonik added the comment: I agree with you on a generic case, where "Special cases aren't special enough to break the rules.", but this special case in ctypes and _anonymous_ context is where the rule "Although practicality beats purity." should apply. Otherwise I can't see any exam

[issue16566] Structure._anonymous_ should not allow strings

2012-11-27 Thread Nick Coghlan
Nick Coghlan added the comment: Yes, if you pass "string" when you meant to pass ["string"], you will often get awful error messages. This is one of the downsides of strings being iterable, but we're not going to add "if isinstance(obj, str): throw TypeError(msg)" special cases everywhere to

[issue16566] Structure._anonymous_ should not allow strings

2012-11-27 Thread Meador Inge
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

[issue16566] Structure._anonymous_ should not allow strings

2012-11-27 Thread anatoly techtonik
anatoly techtonik added the comment: ctypes should throw proper exception if a string is used instead of sequence. It doesn't do this. -- resolution: invalid -> status: closed -> open ___ Python tracker _

[issue16566] Structure._anonymous_ should not allow strings

2012-11-27 Thread STINNER Victor
STINNER Victor added the comment: > An optional sequence that lists the names of unnamed (anonymous) fields Yes, it must be a sequence. > _anonymous_ = '_offset' This is a string, not a sequence. Just use _anonymous_ = ['_offset']. -- nosy: +haypo resolution: -> invalid status: open

[issue16566] Structure._anonymous_ should not allow strings

2012-11-27 Thread anatoly techtonik
anatoly techtonik added the comment: The union definition for the curious: class _OFFSET(Structure): _fields_ = [ ('Offset', DWORD), ('OffsetHigh', DWORD)] class _OFFSET_UNION(Union): _anonymous_ = '_offset' _fields_ = [ ('_off

[issue16566] Structure._anonymous_ should not allow strings

2012-11-27 Thread anatoly techtonik
anatoly techtonik added the comment: s/A_OFFSET_UNION/_OFFSET_UNION/ -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsub

[issue16566] Structure._anonymous_ should not allow strings

2012-11-27 Thread anatoly techtonik
New submission from anatoly techtonik: http://docs.python.org/2/library/ctypes.html#ctypes.Structure._anonymous_ "An optional sequence that lists the names of unnamed (anonymous) fields". If you feed it a string, such as _offset, it will print a very interesting error: ... File "C:\roundu