From 181dff867fc2cd4b6556c88cbac0d954dc6a82cf Mon Sep 17 00:00:00 2001 From: coolreader18 <33094578+coolreader18@users.noreply.github.com> Date: Sat, 28 Dec 2019 20:19:24 -0600 Subject: [PATCH] Fix setting attributes on errors --- vm/src/pyobject.rs | 6 +++--- vm/src/vm.rs | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/vm/src/pyobject.rs b/vm/src/pyobject.rs index e6b6b7312..0fe1cdd17 100644 --- a/vm/src/pyobject.rs +++ b/vm/src/pyobject.rs @@ -1085,7 +1085,7 @@ pub trait PyValue: fmt::Debug + Sized + 'static { fn class(vm: &VirtualMachine) -> PyClassRef; fn into_ref(self, vm: &VirtualMachine) -> PyRef { - self.into_ref_with_type_unchecked(Self::class(vm)) + self.into_ref_with_type_unchecked(Self::class(vm), None) } fn into_ref_with_type(self, vm: &VirtualMachine, cls: PyClassRef) -> PyResult> { @@ -1104,8 +1104,8 @@ pub trait PyValue: fmt::Debug + Sized + 'static { } } - fn into_ref_with_type_unchecked(self, cls: PyClassRef) -> PyRef { - PyRef::new_ref_unchecked(PyObject::new(self, cls, None)) + fn into_ref_with_type_unchecked(self, cls: PyClassRef, dict: Option) -> PyRef { + PyRef::new_ref_unchecked(PyObject::new(self, cls, dict)) } } diff --git a/vm/src/vm.rs b/vm/src/vm.rs index 7a9052039..488f168fb 100644 --- a/vm/src/vm.rs +++ b/vm/src/vm.rs @@ -343,7 +343,8 @@ impl VirtualMachine { ) -> PyBaseExceptionRef { // TODO: add repr of args into logging? vm_trace!("New exception created: {}", exc_type.name); - PyBaseException::new(args, self).into_ref_with_type_unchecked(exc_type) + PyBaseException::new(args, self) + .into_ref_with_type_unchecked(exc_type, Some(self.ctx.new_dict())) } /// Instantiate an exception with no arguments.