Skip to content

del __debug__ should be a SyntaxError #89163

Closed

Description

@aroberge
mannequin
BPO 45000
Nosy @aroberge, @corona10, @lysnikolaou, @pablogsal, @miss-islington
PRs
  • bpo-45000: Raise SyntaxError when try to delete __debug__ #27947
  • bpo-45000: Update whatsnews about deleting __debug__ #27956
  • [3.10] bpo-45000: Raise SyntaxError when try to delete __debug__ (GH-27947) #27957
  • [3.10] bpo-45000: Update whatsnews about deleting __debug__ (GH-27956). #27958
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2021-08-26.09:52:32.700>
    created_at = <Date 2021-08-25.11:50:39.044>
    labels = ['interpreter-core', 'type-bug', '3.10', '3.11']
    title = 'del __debug__ should be a SyntaxError'
    updated_at = <Date 2021-08-26.09:52:32.699>
    user = 'https://github.com/aroberge'

    bugs.python.org fields:

    activity = <Date 2021-08-26.09:52:32.699>
    actor = 'pablogsal'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-08-26.09:52:32.700>
    closer = 'pablogsal'
    components = ['Parser']
    creation = <Date 2021-08-25.11:50:39.044>
    creator = 'aroberge'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 45000
    keywords = ['patch']
    message_count = 5.0
    messages = ['400256', '400277', '400302', '400331', '400332']
    nosy_count = 5.0
    nosy_names = ['aroberge', 'corona10', 'lys.nikolaou', 'pablogsal', 'miss-islington']
    pr_nums = ['27947', '27956', '27957', '27958']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue45000'
    versions = ['Python 3.10', 'Python 3.11']

    Activity

    1. aroberge commented on Aug 25, 2021

      arobergemannequin
      MannequinAuthor

      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.

    2. added
      interpreter-core(Objects, Python, Grammar, and Parser dirs)
      type-bugAn unexpected behavior, bug, or error
      on Aug 25, 2021
    3. miss-islington commented on Aug 25, 2021

      @miss-islington
      Contributor

      New changeset 551da59 by Dong-hee Na in branch 'main':
      bpo-45000: Raise SyntaxError when try to delete __debug__ (GH-27947)
      551da59

    4. corona10 commented on Aug 26, 2021

      @corona10
      Member

      New changeset c764dfb by Dong-hee Na in branch 'main':
      bpo-45000: Update whatsnews about deleting __debug__ (GH-27956)
      c764dfb

    5. pablogsal commented on Aug 26, 2021

      @pablogsal
      Member

      New changeset 6ea6cf2 by Dong-hee Na in branch '3.10':
      [3.10] bpo-45000: Update whatsnews about deleting __debug__ (GH-27956) (GH-27958)
      6ea6cf2

    6. pablogsal commented on Aug 26, 2021

      @pablogsal
      Member

      New changeset 32c1caa by Dong-hee Na in branch '3.10':
      bpo-45000: Raise SyntaxError when try to delete __debug__ (GH-27947) (GH-27957)
      32c1caa

    7. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      3.10 (EOL)end of life3.11only security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions