Skip to content
This repository has been archived by the owner on May 31, 2020. It is now read-only.

Split WITH_CLEANUP into WITH_CLEANUP_START/FINISH #620

Merged
merged 1 commit into from
Aug 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions batavia/VirtualMachine.js
Original file line number Diff line number Diff line change
Expand Up @@ -1761,6 +1761,27 @@ VirtualMachine.prototype.byte_WITH_CLEANUP = function() {
throw new builtins.BataviaError.$pyclass('Confused WITH_CLEANUP')
}
var ret = callables.call_method(mgr, '__exit__', [exc, val, tb])
if (constants.BATAVIA_MAGIC === constants.BATAVIA_MAGIC_34) {
if (!(exc instanceof types.NoneType) && ret.__bool__ !== undefined &&
ret.__bool__().valueOf()) {
this.push('silenced')
}
} else {
// Assuming Python 3.5
Copy link
Member

Choose a reason for hiding this comment

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

Will this code work for 3.5+ or just 3.5?

Copy link
Member

Choose a reason for hiding this comment

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

Depends on when/if they change the opcode. It looks like it's the same for 3.6 (except for the format change - but that's a marshalling issue, not an opcode issue.)

this.push(exc)
this.push(ret)
}
}

VirtualMachine.prototype.byte_WITH_CLEANUP_FINISH = function() {
if (constants.BATAVIA_MAGIC === constants.BATAVIA_MAGIC_34) {
throw new builtins.BataviaError.$pyclass(
'Unknown opcode WITH_CLEANUP_FINISH in Python 3.4'
)
}
// Assuming Python 3.5
var ret = this.pop()
var exc = this.pop()

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

I don't see how your code is failing this check, so I think this is safe to ignore while we still work out bugs in beekeeper.

Copy link
Member

Choose a reason for hiding this comment

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

Hrm... Yeah - not sure what's going on here, because the Beefore check passed...

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

See above

if (!(exc instanceof types.NoneType) && ret.__bool__ !== undefined &&
ret.__bool__().valueOf()) {
this.push('silenced')
Expand Down
3 changes: 3 additions & 0 deletions batavia/modules/dis.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ def_inplace_op('INPLACE_OR', 79)
def_op('BREAK_LOOP', 80)
def_op('WITH_CLEANUP', 81)

// Introduced in Python 3.5
def_op('WITH_CLEANUP_FINISH', 82)

def_op('RETURN_VALUE', 83)
def_op('IMPORT_STAR', 84)

Expand Down