Skip to content

Commit a563d07

Browse files
committed
Fix testEnterAttributeError2 in test_with.py
1 parent 42d7c51 commit a563d07

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

Lib/test/test_with.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,6 @@ def fooLacksEnter():
119119
with foo: pass
120120
self.assertRaisesRegex(AttributeError, '__enter__', fooLacksEnter)
121121

122-
# TODO: RUSTPYTHON
123-
@unittest.expectedFailure
124122
def testEnterAttributeError2(self):
125123
class LacksEnterAndExit(object):
126124
pass

vm/src/frame.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -775,11 +775,13 @@ impl ExecutingFrame<'_> {
775775
}
776776
bytecode::Instruction::SetupWith { end } => {
777777
let context_manager = self.pop_value();
778+
let enter_res = vm.call_special_method(
779+
context_manager.clone(),
780+
identifier!(vm, __enter__),
781+
(),
782+
)?;
778783
let exit = context_manager.get_attr(identifier!(vm, __exit__), vm)?;
779784
self.push_value(exit);
780-
// Call enter:
781-
let enter_res =
782-
vm.call_special_method(context_manager, identifier!(vm, __enter__), ())?;
783785
self.push_block(BlockType::Finally { handler: *end });
784786
self.push_value(enter_res);
785787
Ok(None)

0 commit comments

Comments
 (0)