mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
Issue #27066: Fixed SystemError if a custom opener (for open()) returns
a negative number without setting an exception.
This commit is contained in:
parent
fda4d67842
commit
480e28538d
3 changed files with 25 additions and 1 deletions
|
@ -805,6 +805,22 @@ class IOTest(unittest.TestCase):
|
|||
with self.open("non-existent", "r", opener=opener) as f:
|
||||
self.assertEqual(f.read(), "egg\n")
|
||||
|
||||
def test_bad_opener_negative_1(self):
|
||||
# Issue #27066.
|
||||
def badopener(fname, flags):
|
||||
return -1
|
||||
with self.assertRaises(ValueError) as cm:
|
||||
open('non-existent', 'r', opener=badopener)
|
||||
self.assertEqual(str(cm.exception), 'opener returned -1')
|
||||
|
||||
def test_bad_opener_other_negative(self):
|
||||
# Issue #27066.
|
||||
def badopener(fname, flags):
|
||||
return -2
|
||||
with self.assertRaises(ValueError) as cm:
|
||||
open('non-existent', 'r', opener=badopener)
|
||||
self.assertEqual(str(cm.exception), 'opener returned -2')
|
||||
|
||||
def test_fileio_closefd(self):
|
||||
# Issue #4841
|
||||
with self.open(__file__, 'rb') as f1, \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue