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

Do not leave List elements on the stack after visiting #852

Merged
merged 4 commits into from Jul 2, 2018

Conversation

Projects
None yet
2 participants
@patiences
Copy link
Contributor

commented Jun 27, 2018

When visiting a list node that's being stored into the list object should be popped from the stack when finished (this is already the case for Tuples in ast.py a few lines below my change). This fixes #850.

self.assertCodeExecution("""
try:
[x, y, z, a] = range(3)
except:

This comment has been minimized.

Copy link
@patiences

patiences Jun 27, 2018

Author Contributor

If you are wondering why the exception is ignored, it's because VOC throws a StopIteration while Cpython throws a ValueError (this behavior is known and captured in SequenceTests and they are expected failures).

This comment has been minimized.

Copy link
@patiences

patiences Jun 28, 2018

Author Contributor

Added the tests that catch the correct error in the next commit (as expected failures), so these can be removed when handling bad unpacking of sequences is implemented.

print(y)
print(z)
print(a)
except Exception as e:

This comment has been minimized.

Copy link
@freakboy3742

freakboy3742 Jun 29, 2018

Member

In retrospect, it's probably better to specifically catch StopIteration - that way the test will fail if/when we get around to fix the underlying problem, this test will fail, but hopefully the documentation will point at the way to make the test pass - to delete it :-)

This comment has been minimized.

Copy link
@patiences

patiences Jun 30, 2018

Author Contributor

Yes it would be -- but then the test will fail because there will be no StopIteration to catch on the Python side. Or are you suggesting to use except (StopIteration, ValueError) as e:? I think that when this problem is fixed, the correct test below will result in an unexpected pass, and the comment there should be enough to point the human to delete this test?

This comment has been minimized.

Copy link
@freakboy3742

freakboy3742 Jun 30, 2018

Member

Sorry - yes, I meant to catch (StopIteration, ValueError) as e

This comment has been minimized.

Copy link
@patiences

patiences Jul 1, 2018

Author Contributor

Done! :-)

@patiences patiences referenced this pull request Jun 30, 2018

Merged

Hook up pystone #851

@freakboy3742
Copy link
Member

left a comment

👍

@freakboy3742 freakboy3742 merged commit d7fa15d into beeware:master Jul 2, 2018

5 checks passed

beekeeper:0/beefore:javacheckstyle Java lint checks passed.
Details
beekeeper:0/beefore:pycodestyle Python lint checks passed.
Details
beekeeper:1/smoke-test Smoke build (Python 3.4) passed.
Details
beekeeper:2/full-test:py3.5 Python 3.5 tests passed.
Details
beekeeper:2/full-test:py3.6 Python 3.6 tests passed.
Details

@patiences patiences deleted the patiences:fix-list-bug branch Jul 2, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.