Fix testEnterAttributeError2 in test_with.py

This commit is contained in:
Daeun Lee committed 2022-07-15 22:13:17 +09:00
1 parent 42d7c511f5
commit a563d07919
2 files changed
+5 -5

No files matched your search

-2
View File
@@ -119,8 +119,6 @@ class FailureTestCase(unittest.TestCase):
with foo: pass
self.assertRaisesRegex(AttributeError, '__enter__', fooLacksEnter)
# TODO: RUSTPYTHON
@unittest.expectedFailure
def testEnterAttributeError2(self):
class LacksEnterAndExit(object):
pass
+5 -3
View File
@@ -775,11 +775,13 @@ impl ExecutingFrame<'_> {
}
bytecode::Instruction::SetupWith { end } => {
let context_manager = self.pop_value();
let enter_res = vm.call_special_method(
context_manager.clone(),
identifier!(vm, __enter__),
(),
)?;
let exit = context_manager.get_attr(identifier!(vm, __exit__), vm)?;
self.push_value(exit);
// Call enter:
let enter_res =
vm.call_special_method(context_manager, identifier!(vm, __enter__), ())?;
self.push_block(BlockType::Finally { handler: *end });
self.push_value(enter_res);
Ok(None)