mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-29 11:14:38 +08:00
Use new_os_subtype_error for termios error construction
- Replace manual exception creation with new_os_subtype_error in termios - Remove redundant .to_owned() calls in os.link() error messages
This commit is contained in:
1 parent
24b6f48841
commit
188d438e00
2 files changed
+7
-8
No files matched your search
@@ -261,13 +261,12 @@ mod termios {
|
||||
}
|
||||
|
||||
fn termios_error(err: std::io::Error, vm: &VirtualMachine) -> PyBaseExceptionRef {
|
||||
vm.new_exception(
|
||||
vm.new_os_subtype_error(
|
||||
error_type(vm),
|
||||
vec![
|
||||
err.posix_errno().to_pyobject(vm),
|
||||
vm.ctx.new_str(err.to_string()).into(),
|
||||
],
|
||||
Some(err.posix_errno()),
|
||||
vm.ctx.new_str(err.to_string()),
|
||||
)
|
||||
.upcast()
|
||||
}
|
||||
|
||||
#[pyattr(name = "error", once)]
|
||||
|
||||
@@ -1278,9 +1278,9 @@ pub(super) mod _os {
|
||||
{
|
||||
use std::os::unix::ffi::OsStrExt;
|
||||
let src_cstr = std::ffi::CString::new(src.path.as_os_str().as_bytes())
|
||||
.map_err(|_| vm.new_value_error("embedded null byte".to_owned()))?;
|
||||
.map_err(|_| vm.new_value_error("embedded null byte"))?;
|
||||
let dst_cstr = std::ffi::CString::new(dst.path.as_os_str().as_bytes())
|
||||
.map_err(|_| vm.new_value_error("embedded null byte".to_owned()))?;
|
||||
.map_err(|_| vm.new_value_error("embedded null byte"))?;
|
||||
|
||||
let flags = if follow_symlinks.0 {
|
||||
libc::AT_SYMLINK_FOLLOW
|
||||
@@ -1315,7 +1315,7 @@ pub(super) mod _os {
|
||||
// or raise NotImplementedError if explicitly set to False
|
||||
if !follow_symlinks.0 {
|
||||
return Err(vm.new_not_implemented_error(
|
||||
"link: follow_symlinks unavailable on this platform".to_owned(),
|
||||
"link: follow_symlinks unavailable on this platform",
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user