(vm: &VirtualMachine, module: &Py<PyModule>)
| 1335 | } |
| 1336 | |
| 1337 | pub fn init_module(vm: &VirtualMachine, module: &Py<PyModule>) { |
| 1338 | let ctx = &vm.ctx; |
| 1339 | |
| 1340 | crate::protocol::VecBuffer::make_static_type(); |
| 1341 | |
| 1342 | module.__init_methods(vm).unwrap(); |
| 1343 | builtins::module_exec(vm, module).unwrap(); |
| 1344 | |
| 1345 | let debug_mode: bool = vm.state.config.settings.optimize == 0; |
| 1346 | // Create dynamic ExceptionGroup with multiple inheritance (BaseExceptionGroup + Exception) |
| 1347 | let exception_group = crate::exception_group::exception_group(); |
| 1348 | |
| 1349 | extend_module!(vm, module, { |
| 1350 | "__debug__" => ctx.new_bool(debug_mode), |
| 1351 | |
| 1352 | "bool" => ctx.types.bool_type.to_owned(), |
| 1353 | "bytearray" => ctx.types.bytearray_type.to_owned(), |
| 1354 | "bytes" => ctx.types.bytes_type.to_owned(), |
| 1355 | "classmethod" => ctx.types.classmethod_type.to_owned(), |
| 1356 | "complex" => ctx.types.complex_type.to_owned(), |
| 1357 | "dict" => ctx.types.dict_type.to_owned(), |
| 1358 | "enumerate" => ctx.types.enumerate_type.to_owned(), |
| 1359 | "float" => ctx.types.float_type.to_owned(), |
| 1360 | "frozenset" => ctx.types.frozenset_type.to_owned(), |
| 1361 | "filter" => ctx.types.filter_type.to_owned(), |
| 1362 | "int" => ctx.types.int_type.to_owned(), |
| 1363 | "list" => ctx.types.list_type.to_owned(), |
| 1364 | "map" => ctx.types.map_type.to_owned(), |
| 1365 | "memoryview" => ctx.types.memoryview_type.to_owned(), |
| 1366 | "object" => ctx.types.object_type.to_owned(), |
| 1367 | "property" => ctx.types.property_type.to_owned(), |
| 1368 | "range" => ctx.types.range_type.to_owned(), |
| 1369 | "set" => ctx.types.set_type.to_owned(), |
| 1370 | "slice" => ctx.types.slice_type.to_owned(), |
| 1371 | "staticmethod" => ctx.types.staticmethod_type.to_owned(), |
| 1372 | "str" => ctx.types.str_type.to_owned(), |
| 1373 | "super" => ctx.types.super_type.to_owned(), |
| 1374 | "tuple" => ctx.types.tuple_type.to_owned(), |
| 1375 | "type" => ctx.types.type_type.to_owned(), |
| 1376 | "zip" => ctx.types.zip_type.to_owned(), |
| 1377 | |
| 1378 | // Constants |
| 1379 | "None" => ctx.none(), |
| 1380 | "True" => ctx.new_bool(true), |
| 1381 | "False" => ctx.new_bool(false), |
| 1382 | "NotImplemented" => ctx.not_implemented(), |
| 1383 | "Ellipsis" => vm.ctx.ellipsis.clone(), |
| 1384 | |
| 1385 | // ordered by exception_hierarchy.txt |
| 1386 | // Exceptions: |
| 1387 | "BaseException" => ctx.exceptions.base_exception_type.to_owned(), |
| 1388 | "BaseExceptionGroup" => ctx.exceptions.base_exception_group.to_owned(), |
| 1389 | "ExceptionGroup" => exception_group.to_owned(), |
| 1390 | "SystemExit" => ctx.exceptions.system_exit.to_owned(), |
| 1391 | "KeyboardInterrupt" => ctx.exceptions.keyboard_interrupt.to_owned(), |
| 1392 | "GeneratorExit" => ctx.exceptions.generator_exit.to_owned(), |
| 1393 | "Exception" => ctx.exceptions.exception_type.to_owned(), |
| 1394 | "StopIteration" => ctx.exceptions.stop_iteration.to_owned(), |
nothing calls this directly
no test coverage detected