8000 use identifier & rollback comment · RustPython/RustPython@e53917c · GitHub
[go: up one dir, main page]

Skip to content

Commit e53917c

Browse files
committed
use identifier & rollback comment
1 parent 9d6912c commit e53917c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

vm/src/frame.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,9 +1368,9 @@ impl ExecutingFrame<'_> {
13681368
if let Some(obj) = vm.get_attribute_opt(module.to_owned(), name)? {
13691369
return Ok(obj);
13701370
}
1371-
1371+
// fallback to importing '{module.__name__}.{name}' from sys.modules
13721372
let fallback_module = (|| {
1373-
let mod_name = module.get_attr(&vm.ctx.new_str("__name__"), vm).ok()?;
1373+
let mod_name = module.get_attr(identifier!(vm, __name__), vm).ok()?;
13741374
let mod_name_str = mod_name.downcast_ref::<PyStr>()?;
13751375
let full_mod_name = format!("{}.{}", mod_name_str.as_str(), name.as_str());
13761376
let sys_modules = vm.sys_module.get_attr("modules", vm).ok()?;
@@ -1383,7 +1383,7 @@ impl ExecutingFrame<'_> {
13831383

13841384
if is_module_initializing(module, vm) {
13851385
let module_name = module
1386-
.get_attr(&vm.ctx.new_str("__name__"), vm)
1386+
.get_attr(identifier!(vm, __name__), vm)
13871387
.ok()
13881388
.and_then(|n| n.downcast_ref::<PyStr>().map(|s| s.as_str().to_owned()))
13891389
.unwrap_or_else(|| "<unknown>".to_owned());

0 commit comments

Comments
 (0)
0