From 3b78c6068b37f2229fdd67ddc867e3ee799c00f0 Mon Sep 17 00:00:00 2001 From: Jeong YunWon Date: Tue, 29 Sep 2020 07:46:16 +0900 Subject: [PATCH] vm.class() only for non-static types --- vm/src/stdlib/os.rs | 4 ++-- vm/src/stdlib/time_module.rs | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/vm/src/stdlib/os.rs b/vm/src/stdlib/os.rs index c7d4582ef..f19d4a31a 100644 --- a/vm/src/stdlib/os.rs +++ b/vm/src/stdlib/os.rs @@ -636,7 +636,7 @@ mod _os { #[pyimpl(with(PyStructSequence))] impl StatResult { pub(super) fn into_obj(self, vm: &VirtualMachine) -> PyObjectRef { - self.into_struct_sequence(vm, vm.class(super::MODULE_NAME, "stat_result")) + self.into_struct_sequence(vm, StatResult::static_type().clone()) .unwrap() .into_object() } @@ -1745,7 +1745,7 @@ mod posix { #[pyimpl(with(PyStructSequence))] impl UnameResult { fn into_obj(self, vm: &VirtualMachine) -> PyObjectRef { - self.into_struct_sequence(vm, vm.class(super::MODULE_NAME, "uname_result")) + self.into_struct_sequence(vm, UnameResult::static_type().clone()) .unwrap() .into_object() } diff --git a/vm/src/stdlib/time_module.rs b/vm/src/stdlib/time_module.rs index 15b005a27..ae87411fb 100644 --- a/vm/src/stdlib/time_module.rs +++ b/vm/src/stdlib/time_module.rs @@ -12,7 +12,8 @@ use crate::builtins::pytype::PyTypeRef; use crate::builtins::tuple::PyTupleRef; use crate::function::OptionalArg; use crate::pyobject::{ - BorrowValue, Either, PyClassImpl, PyObjectRef, PyResult, PyStructSequence, TryFromObject, + BorrowValue, Either, PyClassImpl, PyObjectRef, PyResult, PyStructSequence, StaticType, + TryFromObject, }; use crate::vm::VirtualMachine; @@ -218,7 +219,7 @@ impl PyStructTime { } fn into_obj(self, vm: &VirtualMachine) -> PyObjectRef { - self.into_struct_sequence(vm, vm.class("time", "struct_time")) + self.into_struct_sequence(vm, PyStructTime::static_type().clone()) .unwrap() .into_object() }