mirror of
https://github.com/RustPython/Parser.git
synced 2025-07-23 04:55:25 +00:00
Only overwrite the locals in __build_class__ if it's a class
This commit is contained in:
parent
a29fb0de12
commit
fee1b6f2c7
2 changed files with 13 additions and 2 deletions
|
@ -955,12 +955,21 @@ impl<O: OutputStream> Compiler<O> {
|
|||
|
||||
self.emit(Instruction::LoadName {
|
||||
name: "__name__".to_string(),
|
||||
scope: bytecode::NameScope::Free,
|
||||
scope: bytecode::NameScope::Global,
|
||||
});
|
||||
self.emit(Instruction::StoreName {
|
||||
name: "__module__".to_string(),
|
||||
scope: bytecode::NameScope::Free,
|
||||
});
|
||||
self.emit(Instruction::LoadConst {
|
||||
value: bytecode::Constant::String {
|
||||
value: qualified_name.clone(),
|
||||
},
|
||||
});
|
||||
self.emit(Instruction::StoreName {
|
||||
name: "__qualname__".to_string(),
|
||||
scope: bytecode::NameScope::Free,
|
||||
});
|
||||
self.compile_statements(new_body)?;
|
||||
self.emit(Instruction::LoadConst {
|
||||
value: bytecode::Constant::None,
|
||||
|
@ -983,7 +992,7 @@ impl<O: OutputStream> Compiler<O> {
|
|||
|
||||
// Turn code object into function object:
|
||||
self.emit(Instruction::MakeFunction {
|
||||
flags: bytecode::FunctionOpArg::empty(),
|
||||
flags: bytecode::FunctionOpArg::NO_NEW_LOCALS,
|
||||
});
|
||||
|
||||
self.emit(Instruction::LoadConst {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue