mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-29 03:04:38 +08:00
Add Module.__name__
This commit is contained in:
1 parent
e88d6ac1ef
commit
698044b128
2 files changed
+7
No files matched your search
@@ -7,6 +7,8 @@ import import_mutual1
|
||||
assert import_target.X == import_target.func()
|
||||
assert import_target.X == func()
|
||||
|
||||
assert import_mutual1.__name__ == "import_mutual1"
|
||||
|
||||
assert import_target.Y == other_func()
|
||||
|
||||
assert import_target.X == aliased.X
|
||||
|
||||
@@ -23,10 +23,15 @@ impl PyModuleRef {
|
||||
panic!("Modules should definitely have a dict.");
|
||||
}
|
||||
}
|
||||
|
||||
fn name(self: PyModuleRef, _vm: &VirtualMachine) -> String {
|
||||
self.name.clone()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn init(context: &PyContext) {
|
||||
extend_class!(&context, &context.module_type, {
|
||||
"__dir__" => context.new_rustfunc(PyModuleRef::dir),
|
||||
"__name__" => context.new_rustfunc(PyModuleRef::name)
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user