We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent fa9e48a commit 976afedCopy full SHA for 976afed
vm/src/stdlib/re.rs
@@ -112,7 +112,7 @@ struct PyMatch {
112
113
impl PyValue for PyMatch {
114
fn class(vm: &mut VirtualMachine) -> PyObjectRef {
115
- vm.import("re").unwrap().get_attr("Match").unwrap()
+ vm.class("re", "Match")
116
}
117
118
vm/src/vm.rs
@@ -103,6 +103,13 @@ impl VirtualMachine {
103
&frame.scope
104
105
106
+ pub fn class(&mut self, module: &str, class: &str) -> PyObjectRef {
107
+ self.import(module)
108
+ .unwrap_or_else(|_| panic!("unable to import {}", module))
109
+ .get_attr(class)
110
+ .unwrap_or_else(|| panic!("module {} has no class {}", module, class))
111
+ }
+
/// Create a new python string object.
pub fn new_str(&self, s: String) -> PyObjectRef {
self.ctx.new_str(s)
0 commit comments