-
-
Notifications
You must be signed in to change notification settings - Fork 424
Split WITH_CLEANUP into WITH_CLEANUP_START/FINISH #620
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
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() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At column 33: (no-undef) 'opcode' is not defined. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At column 49: (no-undef) 'opname' is not defined. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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') | ||
|
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.)