Skip to content

Commit aa3beda

Browse files
committed
remove meaningless relocation
1 parent d913c45 commit aa3beda

File tree

1 file changed

+25
-26
lines changed

1 file changed

+25
-26
lines changed

vm/src/exceptions.rs

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -949,9 +949,6 @@ impl<C: widestring::UChar> IntoPyException for widestring::NulError<C> {
949949

950950
pub(super) mod types {
951951
use crate::common::lock::PyRwLock;
952-
953-
#[cfg(not(target_arch = "wasm32"))]
954-
use crate::stdlib::errno::errors;
955952
use crate::{
956953
builtins::{traceback::PyTracebackRef, PyInt, PyTupleRef, PyTypeRef},
957954
exceptions::invoke,
@@ -1076,6 +1073,29 @@ pub(super) mod types {
10761073
import_error_init,
10771074
}
10781075

1076+
fn base_exception_new(cls: PyTypeRef, args: FuncArgs, vm: &VirtualMachine) -> PyResult {
1077+
PyBaseException::slot_new(cls, args, vm)
1078+
}
1079+
1080+
fn import_error_init(
1081+
zelf: PyRef<PyBaseException>,
1082+
args: FuncArgs,
1083+
vm: &VirtualMachine,
1084+
) -> PyResult<()> {
1085+
let exc_self = zelf.into_object();
1086+
vm.set_attr(
1087+
&exc_self,
1088+
"name",
1089+
vm.unwrap_or_none(args.kwargs.get("name").cloned()),
1090+
)?;
1091+
vm.set_attr(
1092+
&exc_self,
1093+
"path",
1094+
vm.unwrap_or_none(args.kwargs.get("path").cloned()),
1095+
)?;
1096+
Ok(())
1097+
}
1098+
10791099
define_exception! {
10801100
PyModuleNotFoundError,
10811101
PyImportError,
@@ -1393,6 +1413,8 @@ pub(super) mod types {
13931413
args: Vec<PyObjectRef>,
13941414
vm: &VirtualMachine,
13951415
) -> Option<PyResult<PyBaseExceptionRef>> {
1416+
use crate::stdlib::errno::errors;
1417+
13961418
let len = args.len();
13971419
if len >= 2 {
13981420
let args = args.as_slice();
@@ -1440,10 +1462,6 @@ pub(super) mod types {
14401462
}
14411463
}
14421464

1443-
fn base_exception_new(cls: PyTypeRef, args: FuncArgs, vm: &VirtualMachine) -> PyResult {
1444-
PyBaseException::slot_new(cls, args, vm)
1445-
}
1446-
14471465
#[cfg(not(target_arch = "wasm32"))]
14481466
fn os_error_new(cls: PyTypeRef, args: FuncArgs, vm: &VirtualMachine) -> PyResult {
14491467
// We need this method, because of how `CPython` copies `init`
@@ -1471,23 +1489,4 @@ pub(super) mod types {
14711489
) -> PyResult<()> {
14721490
PyBaseException::init(zelf, args, vm)
14731491
}
1474-
1475-
fn import_error_init(
1476-
zelf: PyRef<PyBaseException>,
1477-
args: FuncArgs,
1478-
vm: &VirtualMachine,
1479-
) -> PyResult<()> {
1480-
let exc_self = zelf.into_object();
1481-
vm.set_attr(
1482-
&exc_self,
1483-
"name",
1484-
vm.unwrap_or_none(args.kwargs.get("name").cloned()),
1485-
)?;
1486-
vm.set_attr(
1487-
&exc_self,
1488-
"path",
1489-
vm.unwrap_or_none(args.kwargs.get("path").cloned()),
1490-
)?;
1491-
Ok(())
1492-
}
14931492
}

0 commit comments

Comments
 (0)