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

`with` statement #594

Merged
merged 1 commit into from Aug 7, 2017

Conversation

Projects
None yet
3 participants
@abonie
Contributor

abonie commented Jul 31, 2017

Implement SETUP_WITH and WITH_CLEANUP opcodes in Batavia's VM

this.push_block(block.type, block.handler, block.level - 1)
} else {
throw new builtins.BataviaError.$pyclass('Confused WITH_CLEANUP')
}

This comment has been minimized.

@brutusthebee

brutusthebee Jul 31, 2017

this.push_block(block.type, block.handler, block.level - 1)
} else {
throw new builtins.BataviaError.$pyclass('Confused WITH_CLEANUP')
}

This comment has been minimized.

@brutusthebee

brutusthebee Jul 31, 2017

This comment has been minimized.

@freakboy3742

freakboy3742 Aug 1, 2017

Member

Not sure what's going on here - the lint problem is genuine; but it's on line 1747.

@freakboy3742

freakboy3742 Aug 1, 2017

Member

Not sure what's going on here - the lint problem is genuine; but it's on line 1747.

This comment has been minimized.

@abonie

abonie Aug 1, 2017

Contributor

I fixed it. The XXX was only there to remind me to double check that this line works as intended. But now I am wondering if I should leave it as is, since it breaks "stack API" by using this.frame.stack.slice instead of combination of this.pop and this.push. The other way feels clunky in this case.

@abonie

abonie Aug 1, 2017

Contributor

I fixed it. The XXX was only there to remind me to double check that this line works as intended. But now I am wondering if I should leave it as is, since it breaks "stack API" by using this.frame.stack.slice instead of combination of this.pop and this.push. The other way feels clunky in this case.

@abonie abonie changed the title from [WIP] `with` statement to `with` statement Aug 2, 2017

Add `with` statement support to VM
Opcodes SETUP_WITH and WITH_CLEANUP has been implemented to trigger
context manager's `__enter__` and `__exit__` methods as necessary and
suppress exceptions when appropriate.

Note that Python 3.5+ replaces WITH_CLEANUP with WITH_CLEANUP_START and
WITH_CLEANUP_FINISH.
@freakboy3742
with approve():
    looks_great()

@freakboy3742 freakboy3742 merged commit 20185c2 into pybee:master Aug 7, 2017

3 checks passed

beekeeper:0/beefore:eslint JavaScript lint checks passed.
Details
beekeeper:0/beefore:pycodestyle Python lint checks passed.
Details
beekeeper:1/smoke-test Smoke build (Python 3.4) passed.
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment