Eryk Sun <eryk...@gmail.com> added the comment:

Field names define CField descriptor attributes on the class. Attribute names 
should be strings, not bytes. There's no syntactically clean way to use a bytes 
name. Consider the example of a generic property on a class:

    >>> T = type('T', (), {b'p': property(lambda s: 0)})
    >>> t = T()
    >>> t.p
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    AttributeError: 'T' object has no attribute 'p'

    >>> getattr(t, b'p')
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: getattr(): attribute name must be string

We'd have to dig into the class dict and manually bind the property:

    >>> vars(T)[b'p'].__get__(t)
    0

----------
nosy: +eryksun
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue33242>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to