Author Tim.Graham
Recipients Tim.Graham, ncoghlan
Date 2016-09-20.12:38:42
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1474375122.62.0.719507311947.issue28214@psf.upfronthosting.co.za>
In-reply-to
Content
As requested by Nick [0], this is a usability issue against CPython 3.6 to provide a better chained TypeError in this case:

class _TokenType(tuple):
    parent = None

    def __getattr__(self, name):
        new = _TokenType(self + (name,))
        setattr(self, name, new)
        new.parent = self
        return new

Token = _TokenType()

Keyword = Token.Keyword

class KeywordCaseFilter(object):
    ttype = Keyword


Traceback (most recent call last):
  File "test.py", line 14, in <module>
    class KeywordCaseFilter(object):
TypeError: '_TokenType' object is not callable

The exception should report the specific object with the problematic __set_name__ attribute (rather than just passing along the underlying exception), as well as supporting __set_name__ = None to explicitly disable further lookup processing.

Follow up to #27366.

[0] https://github.com/andialbrecht/sqlparse/issues/286#issuecomment-248208900
History
Date User Action Args
2016-09-20 12:38:42Tim.Grahamsetrecipients: + Tim.Graham, ncoghlan
2016-09-20 12:38:42Tim.Grahamsetmessageid: <1474375122.62.0.719507311947.issue28214@psf.upfronthosting.co.za>
2016-09-20 12:38:42Tim.Grahamlinkissue28214 messages
2016-09-20 12:38:42Tim.Grahamcreate