@@ -949,9 +949,6 @@ impl<C: widestring::UChar> IntoPyException for widestring::NulError<C> {
949
949
950
950
pub ( super ) mod types {
951
951
use crate :: common:: lock:: PyRwLock ;
952
-
953
- #[ cfg( not( target_arch = "wasm32" ) ) ]
954
- use crate :: stdlib:: errno:: errors;
955
952
use crate :: {
956
953
builtins:: { traceback:: PyTracebackRef , PyInt , PyTupleRef , PyTypeRef } ,
957
954
exceptions:: invoke,
@@ -1076,6 +1073,29 @@ pub(super) mod types {
1076
1073
import_error_init,
1077
1074
}
1078
1075
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
+
1079
1099
define_exception ! {
1080
1100
PyModuleNotFoundError ,
1081
1101
PyImportError ,
@@ -1393,6 +1413,8 @@ pub(super) mod types {
1393
1413
args : Vec < PyObjectRef > ,
1394
1414
vm : & VirtualMachine ,
1395
1415
) -> Option < PyResult < PyBaseExceptionRef > > {
1416
+ use crate :: stdlib:: errno:: errors;
1417
+
1396
1418
let len = args. len ( ) ;
1397
1419
if len >= 2 {
1398
1420
let args = args. as_slice ( ) ;
@@ -1440,10 +1462,6 @@ pub(super) mod types {
1440
1462
}
1441
1463
}
1442
1464
1443
- fn base_exception_new ( cls : PyTypeRef , args : FuncArgs , vm : & VirtualMachine ) -> PyResult {
1444
- PyBaseException :: slot_new ( cls, args, vm)
1445
- }
1446
-
1447
1465
#[ cfg( not( target_arch = "wasm32" ) ) ]
1448
1466
fn os_error_new ( cls : PyTypeRef , args : FuncArgs , vm : & VirtualMachine ) -> PyResult {
1449
1467
// We need this method, because of how `CPython` copies `init`
@@ -1471,23 +1489,4 @@ pub(super) mod types {
1471
1489
) -> PyResult < ( ) > {
1472
1490
PyBaseException :: init ( zelf, args, vm)
1473
1491
}
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
- }
1493
1492
}
0 commit comments