mirror of
https://github.com/python/cpython.git
synced 2025-12-15 21:44:50 +00:00
#4877: Fix a segfault in xml.parsers.expat while attempting to parse a closed file.
This commit is contained in:
parent
7dfc874a48
commit
8b4367ec10
3 changed files with 27 additions and 27 deletions
|
|
@ -6,6 +6,7 @@ import unittest
|
|||
|
||||
from xml.parsers import expat
|
||||
|
||||
from test import test_support
|
||||
from test.test_support import sortdict, run_unittest
|
||||
|
||||
|
||||
|
|
@ -217,6 +218,16 @@ class ParseTest(unittest.TestCase):
|
|||
self.assertEqual(op[15], "External entity ref: (None, u'entity.file', None)")
|
||||
self.assertEqual(op[16], "End element: u'root'")
|
||||
|
||||
# Issue 4877: expat.ParseFile causes segfault on a closed file.
|
||||
fp = open(test_support.TESTFN, 'wb')
|
||||
try:
|
||||
fp.close()
|
||||
parser = expat.ParserCreate()
|
||||
with self.assertRaises(ValueError):
|
||||
parser.ParseFile(fp)
|
||||
finally:
|
||||
test_support.unlink(test_support.TESTFN)
|
||||
|
||||
|
||||
class NamespaceSeparatorTest(unittest.TestCase):
|
||||
def test_legal(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue