mirror of
https://github.com/RustPython/Parser.git
synced 2025-09-03 09:07:54 +00:00
Merge pull request #2544 from RustPython/coolreader18/misc-fixes
Misc fixes related to IPython
This commit is contained in:
commit
1ab3589844
1 changed files with 4 additions and 11 deletions
|
@ -1391,22 +1391,18 @@ impl Compiler {
|
||||||
// The thing iterated:
|
// The thing iterated:
|
||||||
self.compile_expression(iter)?;
|
self.compile_expression(iter)?;
|
||||||
|
|
||||||
let check_asynciter_block = if is_async {
|
if is_async {
|
||||||
let check_asynciter_block = self.new_block();
|
|
||||||
|
|
||||||
self.emit(Instruction::GetAIter);
|
self.emit(Instruction::GetAIter);
|
||||||
|
|
||||||
self.switch_to_block(for_block);
|
self.switch_to_block(for_block);
|
||||||
self.emit(Instruction::SetupExcept {
|
self.emit(Instruction::SetupExcept {
|
||||||
handler: check_asynciter_block,
|
handler: else_block,
|
||||||
});
|
});
|
||||||
self.emit(Instruction::GetANext);
|
self.emit(Instruction::GetANext);
|
||||||
self.emit_constant(ConstantData::None);
|
self.emit_constant(ConstantData::None);
|
||||||
self.emit(Instruction::YieldFrom);
|
self.emit(Instruction::YieldFrom);
|
||||||
self.compile_store(target)?;
|
self.compile_store(target)?;
|
||||||
self.emit(Instruction::PopBlock);
|
self.emit(Instruction::PopBlock);
|
||||||
|
|
||||||
Some(check_asynciter_block)
|
|
||||||
} else {
|
} else {
|
||||||
// Retrieve Iterator
|
// Retrieve Iterator
|
||||||
self.emit(Instruction::GetIter);
|
self.emit(Instruction::GetIter);
|
||||||
|
@ -1416,7 +1412,6 @@ impl Compiler {
|
||||||
|
|
||||||
// Start of loop iteration, set targets:
|
// Start of loop iteration, set targets:
|
||||||
self.compile_store(target)?;
|
self.compile_store(target)?;
|
||||||
None
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let was_in_loop = self.ctx.loop_data;
|
let was_in_loop = self.ctx.loop_data;
|
||||||
|
@ -1425,12 +1420,10 @@ impl Compiler {
|
||||||
self.ctx.loop_data = was_in_loop;
|
self.ctx.loop_data = was_in_loop;
|
||||||
self.emit(Instruction::Jump { target: for_block });
|
self.emit(Instruction::Jump { target: for_block });
|
||||||
|
|
||||||
if let Some(check_asynciter_block) = check_asynciter_block {
|
self.switch_to_block(else_block);
|
||||||
self.switch_to_block(check_asynciter_block);
|
if is_async {
|
||||||
self.emit(Instruction::EndAsyncFor);
|
self.emit(Instruction::EndAsyncFor);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.switch_to_block(else_block);
|
|
||||||
self.emit(Instruction::PopBlock);
|
self.emit(Instruction::PopBlock);
|
||||||
self.compile_statements(orelse)?;
|
self.compile_statements(orelse)?;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue