Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

del __debug__ should be a SyntaxError #89163

Closed
aroberge mannequin opened this issue Aug 25, 2021 · 5 comments
Closed

del __debug__ should be a SyntaxError #89163

aroberge mannequin opened this issue Aug 25, 2021 · 5 comments
Labels
3.10 only security fixes 3.11 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@aroberge
Copy link
Mannequin

aroberge mannequin commented Aug 25, 2021

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']

    @aroberge
    Copy link
    Mannequin Author

    aroberge mannequin commented Aug 25, 2021

    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.

    @aroberge aroberge mannequin added 3.10 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error labels Aug 25, 2021
    @miss-islington
    Copy link
    Contributor

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

    @corona10 corona10 added 3.11 only security fixes labels Aug 25, 2021
    @corona10
    Copy link
    Member

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

    @pablogsal
    Copy link
    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

    @pablogsal
    Copy link
    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

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.10 only security fixes 3.11 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants