This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Alex Mashianov
Recipients Alex Mashianov
Date 2018-08-27.08:42:26
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1535359346.38.0.56676864532.issue34517@psf.upfronthosting.co.za>
In-reply-to
Content
This code:
class A:
    a = 1
    b = {str(x): x for x in range(5) if x != a}

Produces following error:
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "<input>", line 3, in A
  File "<input>", line 3, in <dictcomp>
NameError: name 'a' is not defined


Which i think it shouldn't produce. Issue occurs only in dict comprehensions inside class definitions referencing class attributes(which are in local scope during definition).
History
Date User Action Args
2018-08-27 08:42:26Alex Mashianovsetrecipients: + Alex Mashianov
2018-08-27 08:42:26Alex Mashianovsetmessageid: <1535359346.38.0.56676864532.issue34517@psf.upfronthosting.co.za>
2018-08-27 08:42:26Alex Mashianovlinkissue34517 messages
2018-08-27 08:42:26Alex Mashianovcreate