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

bpo-37947: Avoid double-decrement in symtable recursion counting #15593

Merged

Conversation

ncoghlan
Copy link
Contributor

@ncoghlan ncoghlan commented Aug 29, 2019

With symtable_visit_expr now correctly adjusting the recursion depth for named
expressions, symtable_handle_namedexpr should be leaving it alone.

https://bugs.python.org/issue37947

Copy link
Member

@pablogsal pablogsal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Thank you for correcting this!

@ncoghlan
Copy link
Contributor Author

I think I've found a good spot to add a sanity check that will make the test cases fail if a PR gets this accounting wrong - building that now (and I'll test it out by partially reverting the previous change).

@ncoghlan
Copy link
Contributor Author

Neat:

======================================================================
ERROR: test_named_expression_variable_reuse_in_comprehensions (test.test_named_expressions.NamedExpressionScopeTest) (case='Nested nonlocal')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/ncoghlan/devel/cpython/Lib/test/test_named_expressions.py", line 469, in test_named_expression_variable_reuse_in_comprehensions
    exec(code, ns)
SystemError: symtable analysis recursion depth mismatch (before=96, after=95)

(This is with VISIT_QUIT(st, 1) at the end of symtable_handle_namedexpr)

@ncoghlan ncoghlan merged commit 0614523 into python:master Aug 29, 2019
@ncoghlan ncoghlan deleted the bpo-37947-symtable-recursion-counting branch August 29, 2019 13:26
@miss-islington
Copy link
Contributor

Thanks @ncoghlan for the PR 🌮🎉.. I'm working now to backport this PR to: 3.8.
🐍🍒⛏🤖

@bedevere-bot
Copy link

GH-15594 is a backport of this pull request to the 3.8 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Aug 29, 2019
…honGH-15593)

With `symtable_visit_expr` now correctly adjusting the recursion depth for named
expressions, `symtable_handle_namedexpr` should be leaving it alone.

Also adds a new check to `PySymtable_BuildObject` that raises `SystemError`
if a successful first symbol analysis pass fails to keep the stack depth
accounting clean.
(cherry picked from commit 0614523)

Co-authored-by: Nick Coghlan <ncoghlan@gmail.com>
miss-islington added a commit that referenced this pull request Aug 29, 2019
…15593)

With `symtable_visit_expr` now correctly adjusting the recursion depth for named
expressions, `symtable_handle_namedexpr` should be leaving it alone.

Also adds a new check to `PySymtable_BuildObject` that raises `SystemError`
if a successful first symbol analysis pass fails to keep the stack depth
accounting clean.
(cherry picked from commit 0614523)

Co-authored-by: Nick Coghlan <ncoghlan@gmail.com>
lisroach pushed a commit to lisroach/cpython that referenced this pull request Sep 10, 2019
…honGH-15593)

With `symtable_visit_expr` now correctly adjusting the recursion depth for named
expressions, `symtable_handle_namedexpr` should be leaving it alone.

Also adds a new check to `PySymtable_BuildObject` that raises `SystemError`
if a successful first symbol analysis pass fails to keep the stack depth
accounting clean.
DinoV pushed a commit to DinoV/cpython that referenced this pull request Jan 14, 2020
…honGH-15593)

With `symtable_visit_expr` now correctly adjusting the recursion depth for named
expressions, `symtable_handle_namedexpr` should be leaving it alone.

Also adds a new check to `PySymtable_BuildObject` that raises `SystemError`
if a successful first symbol analysis pass fails to keep the stack depth
accounting clean.
websurfer5 pushed a commit to websurfer5/cpython that referenced this pull request Jul 20, 2020
…honGH-15593)

With `symtable_visit_expr` now correctly adjusting the recursion depth for named
expressions, `symtable_handle_namedexpr` should be leaving it alone.

Also adds a new check to `PySymtable_BuildObject` that raises `SystemError`
if a successful first symbol analysis pass fails to keep the stack depth
accounting clean.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants