Fix panic on import statement with levels but no module name. · ugaemi/RustPython@ce1523c · GitHub
Skip to content

Commit ce1523c

Browse files
committed
Fix panic on import statement with levels but no module name.
1 parent 19e783d commit ce1523c

3 files changed

Lines changed: 23 additions & 11 deletions

File tree

bytecode/src/bytecode.rs

Lines changed: 9 additions & 4 deletions

compiler/src/compile.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ impl Compiler {
271271
// import a, b, c as d
272272
for name in names {
273273
self.emit(Instruction::Import {
274-
name: name.symbol.clone(),
274+
name: Some(name.symbol.clone()),
275275
symbols: vec![],
276276
level: 0,
277277
});
@@ -293,7 +293,7 @@ impl Compiler {
293293
if import_star {
294294
// from .... import *
295295
self.emit(Instruction::ImportStar {
296-
name: module.clone().unwrap(),
296+
name: module.clone(),
297297
level: *level,
298298
});
299299
} else {
@@ -303,7 +303,7 @@ impl Compiler {
303303

304304
// Load module once:
305305
self.emit(Instruction::Import {
306-
name: module.clone().unwrap(),
306+
name: module.clone(),
307307
symbols: from_list,
308308
level: *level,
309309
});

vm/src/frame.rs

Lines changed: 11 additions & 4 deletions

0 commit comments

Comments
 (0)