GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — gh-104374: Remove access to class scopes for inlined comprehensions by JelleZijlstra · Pull Request #104528 · python/cpython Conversation
|
|
Found the following crash with a variation of Carl's fuzzer: This doesn't reproduce on main, so it's new from this PR. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Found a different issue trying to simplify it: |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
The problem occurs if it's a cell var in the outer comprehension and a free var in the inner one. In that case we should just do LOAD_FAST, but right now we're probably emitting _DEREF opcodes that explode because those cells don't exist in the class namespace. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I pushed a fix for the above issues; it's just a matter of correcting how we decide if a comprehension is "in a class block." Looking only at |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| def test_nested_free_var_in_iter(self): | ||
| code = """ | ||
| items = [_C for _C in [1] for [0, 1][[x for x in [1] if _C][0]] in [2]] |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Would be nice if we could test here that the name resolution in the inner listcomp here is right. I'll try to come up with some more tests around nested listcomps.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Are you still planning to add more tests here, or improve this one?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Yes, will push some more tests today or tomorrow. If you'd prefer to merge this now we can also do that; I can just write more tests in another PR.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think if we get known fixes merged sooner it's easier to do more effective fuzz testing; if we find more issues we can fix them in separate PRs, and we can add more tests that we think of in separate PRs.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Just added two more tests and turned on automerge.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Now this segfaults: Haven't tried to minimize it, but it's a compiler crash, something related to the cell/freevars: |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Reduced: def a(): class a: [(lambda : b) for b in [a]] print(b) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
This also reproduces on main (without this PR) and with two functions, so it's not just related to class scopes: def a(): def a(): [(lambda : b) for b in [a]] print(b) Crashes on current main with the same backtrace as above. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks, I'll open a separate issue and PR for this. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| def test_nested_free_var_in_iter(self): | ||
| code = """ | ||
| items = [_C for _C in [1] for [0, 1][[x for x in [1] if _C][0]] in [2]] |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Are you still planning to add more tests here, or improve this one?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.