mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-09 22:49:57 +09:00
Fix setting attributes on errors
This commit is contained in:
@@ -1085,7 +1085,7 @@ pub trait PyValue: fmt::Debug + Sized + 'static {
|
||||
fn class(vm: &VirtualMachine) -> PyClassRef;
|
||||
|
||||
fn into_ref(self, vm: &VirtualMachine) -> PyRef<Self> {
|
||||
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<PyRef<Self>> {
|
||||
@@ -1104,8 +1104,8 @@ pub trait PyValue: fmt::Debug + Sized + 'static {
|
||||
}
|
||||
}
|
||||
|
||||
fn into_ref_with_type_unchecked(self, cls: PyClassRef) -> PyRef<Self> {
|
||||
PyRef::new_ref_unchecked(PyObject::new(self, cls, None))
|
||||
fn into_ref_with_type_unchecked(self, cls: PyClassRef, dict: Option<PyDictRef>) -> PyRef<Self> {
|
||||
PyRef::new_ref_unchecked(PyObject::new(self, cls, dict))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user