[New-bugs-announce] [issue45000] del __debug__ should be a SyntaxError
Andre Roberge
report at bugs.python.org
Wed Aug 25 07:50:39 EDT 2021
New submission from Andre Roberge <andre.roberge at gmail.com>:
Consider the following:
Python 3.10.0rc1 ...
>>> __debug__
True
>>> del __debug__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name '__debug__' is not defined
>>> __debug__
True
>>> __debug__ = False
File "<stdin>", line 1
SyntaxError: cannot assign to __debug__
I suggest that attempting to delete __debug__ should be a SyntaxError, similar to attempting to delete None and other constants.
>>> del None
File "<stdin>", line 1
del None
^^^^
SyntaxError: cannot delete None
= = =
The same NameError exception is raised for Python 3.9 when attempting to delete __debug__. For Python 3.8, attempting to delete __debug__ silently fails, so the current behaviour is at least an improvement.
----------
components: Parser
messages: 400256
nosy: aroberge, lys.nikolaou, pablogsal
priority: normal
severity: normal
status: open
title: del __debug__ should be a SyntaxError
type: behavior
versions: Python 3.10
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45000>
_______________________________________
More information about the New-bugs-announce
mailing list