mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-29 03:04:38 +08:00
Fix testEnterAttributeError2 in test_with.py
This commit is contained in:
1 parent
42d7c511f5
commit
a563d07919
2 files changed
+5
-5
No files matched your search
Vendored
-2
@@ -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
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user