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.

classification
Title: del __debug__ should be a SyntaxError
Type: behavior Stage: resolved
Components: Parser Versions: Python 3.11, Python 3.10
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: aroberge, corona10, lys.nikolaou, miss-islington, pablogsal
Priority: normal Keywords: patch

Created on 2021-08-25 11:50 by aroberge, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 27947 merged corona10, 2021-08-25 14:14
PR 27956 merged corona10, 2021-08-25 23:58
PR 27957 merged corona10, 2021-08-26 00:03
PR 27958 merged corona10, 2021-08-26 00:38
Messages (5)
msg400256 - (view) Author: Andre Roberge (aroberge) * Date: 2021-08-25 11:50
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.
msg400277 - (view) Author: miss-islington (miss-islington) Date: 2021-08-25 17:54
New changeset 551da597a0996b0fb3af425f48aa5bc63ea6b963 by Dong-hee Na in branch 'main':
bpo-45000: Raise SyntaxError when try to delete __debug__ (GH-27947)
https://github.com/python/cpython/commit/551da597a0996b0fb3af425f48aa5bc63ea6b963
msg400302 - (view) Author: Dong-hee Na (corona10) * (Python committer) Date: 2021-08-26 00:36
New changeset c764dfbcbc12c4653fc8ab39773cf973c9db2757 by Dong-hee Na in branch 'main':
bpo-45000: Update whatsnews about deleting __debug__ (GH-27956)
https://github.com/python/cpython/commit/c764dfbcbc12c4653fc8ab39773cf973c9db2757
msg400331 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-08-26 09:52
New changeset 6ea6cf22e9d084c27a4fffbbd298098a6ad5b776 by Dong-hee Na in branch '3.10':
[3.10] bpo-45000: Update whatsnews about deleting __debug__ (GH-27956) (GH-27958)
https://github.com/python/cpython/commit/6ea6cf22e9d084c27a4fffbbd298098a6ad5b776
msg400332 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-08-26 09:52
New changeset 32c1caa87f68a650f2d009a589a1db30484499cb by Dong-hee Na in branch '3.10':
bpo-45000: Raise SyntaxError when try to delete __debug__ (GH-27947) (GH-27957)
https://github.com/python/cpython/commit/32c1caa87f68a650f2d009a589a1db30484499cb
History
Date User Action Args
2022-04-11 14:59:49adminsetgithub: 89163
2021-08-26 09:52:32pablogsalsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2021-08-26 09:52:30pablogsalsetmessages: + msg400332
2021-08-26 09:52:10pablogsalsetmessages: + msg400331
2021-08-26 00:38:08corona10setpull_requests: + pull_request26404
2021-08-26 00:36:31corona10setmessages: + msg400302
2021-08-26 00:03:25corona10setpull_requests: + pull_request26403
2021-08-25 23:58:49corona10setpull_requests: + pull_request26402
2021-08-25 23:54:26corona10setversions: + Python 3.11
2021-08-25 17:54:33miss-islingtonsetnosy: + miss-islington
messages: + msg400277
2021-08-25 14:14:46corona10setkeywords: + patch
stage: patch review
pull_requests: + pull_request26394
2021-08-25 14:12:36corona10setnosy: + corona10
2021-08-25 11:50:39arobergecreate