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 serhiy.storchaka
Recipients emilyemorehouse, gvanrossum, serhiy.storchaka
Date 2019-02-20.15:23:36
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1550676216.29.0.487544148429.issue36052@roundup.psfhosted.org>
In-reply-to
Content
All ways of assigning to __debug__ are forbidden:

>>> __debug__ = 1
  File "<stdin>", line 1
SyntaxError: cannot assign to __debug__
>>> for __debug__ in []: pass
... 
  File "<stdin>", line 1
SyntaxError: cannot assign to __debug__
>>> with cm() as __debug__: pass
... 
  File "<stdin>", line 1
SyntaxError: cannot assign to __debug__
>>> class __debug__: pass
... 
  File "<stdin>", line 1
SyntaxError: cannot assign to __debug__
>>> def __debug__(): pass
... 
  File "<stdin>", line 1
SyntaxError: cannot assign to __debug__
>>> def foo(__debug__): pass
... 
  File "<stdin>", line 1
SyntaxError: cannot assign to __debug__
>>> import __debug__
  File "<stdin>", line 1
SyntaxError: cannot assign to __debug__

The only exception is the assignment operator.

>>> (__debug__ := 'spam')
'spam'
>>> globals()['__debug__']
'spam'

This looks like a bug.
History
Date User Action Args
2019-02-20 15:23:36serhiy.storchakasetrecipients: + serhiy.storchaka, gvanrossum, emilyemorehouse
2019-02-20 15:23:36serhiy.storchakasetmessageid: <1550676216.29.0.487544148429.issue36052@roundup.psfhosted.org>
2019-02-20 15:23:36serhiy.storchakalinkissue36052 messages
2019-02-20 15:23:36serhiy.storchakacreate