mirror of
https://github.com/python/cpython.git
synced 2025-09-02 15:07:53 +00:00
Issue #15261: Stop os.stat(fd) crashing on Windows when fd not open.
This commit is contained in:
parent
74de153681
commit
2240ac1eae
5 changed files with 37 additions and 6 deletions
|
@ -473,6 +473,19 @@ class StatAttributeTests(unittest.TestCase):
|
|||
return
|
||||
self.fail("Could not stat pagefile.sys")
|
||||
|
||||
@unittest.skipUnless(hasattr(os, "pipe"), "requires os.pipe()")
|
||||
def test_15261(self):
|
||||
# Verify that stat'ing a closed fd does not cause crash
|
||||
r, w = os.pipe()
|
||||
try:
|
||||
os.stat(r) # should not raise error
|
||||
finally:
|
||||
os.close(r)
|
||||
os.close(w)
|
||||
with self.assertRaises(OSError) as ctx:
|
||||
os.stat(r)
|
||||
self.assertEqual(ctx.exception.errno, errno.EBADF)
|
||||
|
||||
from test import mapping_tests
|
||||
|
||||
class EnvironTests(mapping_tests.BasicTestMappingProtocol):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue