MCPcopy Index your code
hub / github.com/RustPython/RustPython / build

Method build

crates/vm/src/exceptions.rs:1334–1372  ·  view source on GitHub ↗
(self, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

1332 }
1333
1334 pub fn build(self, vm: &VirtualMachine) -> PyRef<types::PyOSError> {
1335 use types::PyOSError;
1336
1337 let OSErrorBuilder {
1338 exc_type,
1339 errno,
1340 strerror,
1341 filename,
1342 #[cfg(windows)]
1343 winerror,
1344 filename2,
1345 } = self;
1346
1347 let args = if let Some(errno) = errno {
1348 #[cfg(windows)]
1349 let winerror = winerror.to_pyobject(vm);
1350 #[cfg(not(windows))]
1351 let winerror = vm.ctx.none();
1352
1353 vec![
1354 errno.to_pyobject(vm),
1355 strerror.to_pyobject(vm),
1356 filename.to_pyobject(vm),
1357 winerror,
1358 filename2.to_pyobject(vm),
1359 ]
1360 } else {
1361 vec![strerror.to_pyobject(vm)]
1362 };
1363
1364 let payload = PyOSError::py_new(&exc_type, args.clone().into(), vm)
1365 .expect("new_os_error usage error");
1366 let os_error = payload
1367 .into_ref_with_type(vm, exc_type)
1368 .expect("new_os_error usage error");
1369 PyOSError::slot_init(os_error.as_object().to_owned(), args.into(), vm)
1370 .expect("new_os_error usage error");
1371 os_error
1372 }
1373}
1374
1375impl IntoPyException for OSErrorBuilder {

Callers 11

interpreter_with_vmFunction · 0.45
bench_rustpython_codeFunction · 0.45
bench_rustpython_codeFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45
newMethod · 0.45
into_pyexceptionMethod · 0.45
newMethod · 0.45
with_filenameMethod · 0.45

Calls 6

noneMethod · 0.80
into_ref_with_typeMethod · 0.80
to_pyobjectMethod · 0.45
cloneMethod · 0.45
to_ownedMethod · 0.45
as_objectMethod · 0.45

Tested by

no test coverage detected