Skip to content

Commit 57f44c6

Browse files
committed
fix
1 parent 068a99c commit 57f44c6

File tree

2 files changed

+10
-19
lines changed

2 files changed

+10
-19
lines changed

crates/codegen/src/compile.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7609,6 +7609,14 @@ impl Compiler {
76097609
compiler.compile_comprehension_element(elt)?;
76107610

76117611
compiler.mark_generator();
7612+
if compiler.ctx.func == FunctionContext::AsyncFunction {
7613+
emit!(
7614+
compiler,
7615+
Instruction::CallIntrinsic1 {
7616+
func: bytecode::IntrinsicFunction1::AsyncGenWrap
7617+
}
7618+
);
7619+
}
76127620
// arg=0: direct yield (wrapped for async generators)
76137621
emit!(compiler, Instruction::YieldValue { arg: 0 });
76147622
emit!(

crates/vm/src/frame.rs

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use crate::{
1010
PyBaseException, PyBaseExceptionRef, PyBaseObject, PyCode, PyCoroutine, PyDict, PyDictRef,
1111
PyFloat, PyFrozenSet, PyGenerator, PyInt, PyInterpolation, PyList, PyModule, PyProperty,
1212
PySet, PySlice, PyStr, PyStrInterned, PyTemplate, PyTraceback, PyType, PyUtf8Str,
13-
asyncgenerator::PyAsyncGenWrappedValue,
1413
builtin_func::PyNativeFunction,
1514
descriptor::{MemberGetter, PyMemberDescriptor, PyMethodDescriptor},
1615
frame::stack_analysis,
@@ -3548,7 +3547,7 @@ impl ExecutingFrame<'_> {
35483547

35493548
Ok(None)
35503549
}
3551-
Instruction::YieldValue { arg: oparg } => {
3550+
Instruction::YieldValue { .. } => {
35523551
debug_assert!(
35533552
self.localsplus
35543553
.stack_as_slice()
@@ -3557,16 +3556,7 @@ impl ExecutingFrame<'_> {
35573556
.all(|sr| !sr.is_borrowed()),
35583557
"borrowed refs on stack at yield point"
35593558
);
3560-
let value = self.pop_value();
3561-
// arg=0: direct yield (wrapped for async generators)
3562-
// arg=1: yield from await/yield-from (NOT wrapped)
3563-
let wrap = oparg.get(arg) == 0;
3564-
let value = if wrap && self.code.flags.contains(bytecode::CodeFlags::COROUTINE) {
3565-
PyAsyncGenWrappedValue(value).into_pyobject(vm)
3566-
} else {
3567-
value
3568-
};
3569-
Ok(Some(ExecutionResult::Yield(value)))
3559+
Ok(Some(ExecutionResult::Yield(self.pop_value())))
35703560
}
35713561
Instruction::Send { .. } => {
35723562
// (receiver, v -- receiver, retval)
@@ -5800,13 +5790,6 @@ impl ExecutingFrame<'_> {
58005790
let offset = (self.lasti() - 1) * 2;
58015791
monitoring::fire_py_yield(vm, self.code, offset, &value)?;
58025792
}
5803-
let oparg = u32::from(arg);
5804-
let wrap = oparg == 0;
5805-
let value = if wrap && self.code.flags.contains(bytecode::CodeFlags::COROUTINE) {
5806-
PyAsyncGenWrappedValue(value).into_pyobject(vm)
5807-
} else {
5808-
value
5809-
};
58105793
Ok(Some(ExecutionResult::Yield(value)))
58115794
}
58125795
Instruction::InstrumentedCall => {

0 commit comments

Comments
 (0)