forked from Rust-related/RustPython
stdlib/io.rs: align negative-fd-from-opener exception with CPython
This commit is contained in:
4
Lib/test/test_io.py
vendored
4
Lib/test/test_io.py
vendored
@@ -864,8 +864,6 @@ class IOTest(unittest.TestCase):
|
||||
with self.open("non-existent", "r", opener=opener) as f:
|
||||
self.assertEqual(f.read(), "egg\n")
|
||||
|
||||
# TODO: RUSTPYTHON
|
||||
@unittest.expectedFailure
|
||||
def test_bad_opener_negative_1(self):
|
||||
# Issue #27066.
|
||||
def badopener(fname, flags):
|
||||
@@ -874,8 +872,6 @@ class IOTest(unittest.TestCase):
|
||||
open('non-existent', 'r', opener=badopener)
|
||||
self.assertEqual(str(cm.exception), 'opener returned -1')
|
||||
|
||||
# TODO: RUSTPYTHON
|
||||
@unittest.expectedFailure
|
||||
def test_bad_opener_other_negative(self):
|
||||
# Issue #27066.
|
||||
def badopener(fname, flags):
|
||||
|
||||
@@ -3857,7 +3857,7 @@ mod fileio {
|
||||
}
|
||||
let fd = i32::try_from_object(vm, fd)?;
|
||||
if fd < 0 {
|
||||
return Err(vm.new_os_error("Negative file descriptor".to_owned()));
|
||||
return Err(vm.new_value_error(format!("opener returned {}", fd)));
|
||||
}
|
||||
fd
|
||||
} else if let Some(i) = name.payload::<crate::builtins::PyInt>() {
|
||||
|
||||
Reference in New Issue
Block a user