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

SystemError when compiling deeply nested for loops #71701

Closed
pppery mannequin opened this issue Jul 14, 2016 · 7 comments
Closed

SystemError when compiling deeply nested for loops #71701

pppery mannequin opened this issue Jul 14, 2016 · 7 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@pppery
Copy link
Mannequin

pppery mannequin commented Jul 14, 2016

BPO 27514
Nosy @brettcannon, @birkenfeld, @ncoghlan, @benjaminp, @serhiy-storchaka, @1st1, @pppery, @ammaraskar
Files
  • nested_blocks.diff
  • nested_blocks.diff2
  • 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 2016-07-15.05:02:21.177>
    created_at = <Date 2016-07-14.12:33:51.333>
    labels = ['interpreter-core', 'type-bug']
    title = 'SystemError when compiling deeply nested for loops'
    updated_at = <Date 2016-07-15.05:02:21.167>
    user = 'https://github.com/pppery'

    bugs.python.org fields:

    activity = <Date 2016-07-15.05:02:21.167>
    actor = 'python-dev'
    assignee = 'none'
    closed = True
    closed_date = <Date 2016-07-15.05:02:21.177>
    closer = 'python-dev'
    components = ['Interpreter Core']
    creation = <Date 2016-07-14.12:33:51.333>
    creator = 'ppperry'
    dependencies = []
    files = ['43725', '43726']
    hgrepos = []
    issue_num = 27514
    keywords = ['patch']
    message_count = 7.0
    messages = ['270405', '270409', '270410', '270445', '270446', '270462', '270464']
    nosy_count = 9.0
    nosy_names = ['brett.cannon', 'georg.brandl', 'ncoghlan', 'benjamin.peterson', 'python-dev', 'serhiy.storchaka', 'yselivanov', 'ppperry', 'ammar2']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue27514'
    versions = ['Python 2.7', 'Python 3.5', 'Python 3.6']

    @pppery
    Copy link
    Mannequin Author

    pppery mannequin commented Jul 14, 2016

    The following code:
    for a in range(26):
    for b in range(26):
    for c in range(26):
    for d in range(26):
    for e in range(26):
    for f in range(26):
    for g in range(26):
    for h in range(26):
    for i in range(26):
    for j in range(26):
    for k in range(26):
    for l in range(26):
    for m in range(26):
    for o in range(26):
    for p in range(26):
    for q in range(26):
    for r in range(26):
    for s in range(26):
    for t in range(26):
    for u in range(26):
    for v in range(26):
    for w in range(26):
    pass
    fails to compile with SystemError:too many statically nested blocks, which was described as a serious bug in bpo-27081.

    @pppery pppery mannequin added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error labels Jul 14, 2016
    @serhiy-storchaka
    Copy link
    Member

    There is a static limit for the number of statically nested blocks. Getting rid of this limit looks not easy.

    But SystemError is not an exception that should be raised. SystemError is for errors that can't be occurred in normal case. It should only be caused by incorrect use of C API or hacking Python internals. I think SyntaxError is more appropriate in this case (as in case of passing more than 255 arguments to a function).

    @ncoghlan
    Copy link
    Contributor

    +1 for Serhiy's recommendation. It's OK for the compiler to say "Don't do that", but the correct error is SyntaxError, even when it's a limitation later in the code generation pipeline (rather than failing to comply with the language grammar)

    @ammaraskar
    Copy link
    Member

    This patch changes it to a SyntaxError instead of a SystemError.

    @ammaraskar
    Copy link
    Member

    Amended patch with the comment fixed to refer to just the issue numbers according to advice from bitdancer.

    @serhiy-storchaka
    Copy link
    Member

    LGTM.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Jul 15, 2016

    New changeset e6e7c8368c70 by Benjamin Peterson in branch '3.5':
    make too many nested blocks be a SyntaxError instead of a SystemError (closes bpo-27514)
    https://hg.python.org/cpython/rev/e6e7c8368c70

    New changeset 345ec7455b75 by Benjamin Peterson in branch '2.7':
    make too many nested blocks be a SyntaxError instead of a SystemError (closes bpo-27514)
    https://hg.python.org/cpython/rev/345ec7455b75

    New changeset d1da87d8b29c by Benjamin Peterson in branch 'default':
    merge 3.5 (bpo-27514)
    https://hg.python.org/cpython/rev/d1da87d8b29c

    @python-dev python-dev mannequin closed this as completed Jul 15, 2016
    @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
    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