summaryrefslogtreecommitdiff
path: root/Lib/test
diff options
context:
space:
mode:
authorEzio Melotti <none@none>2011-04-11 03:44:28 +0300
committerEzio Melotti <none@none>2011-04-11 03:44:28 +0300
commit8b4367ec10c0518b06a8291f4313ef7677d85988 (patch)
tree9e902463f32196131c44779e49756f688b7f2aed /Lib/test
parent7dfc874a48516e58e830b3a455fca34c8cd834eb (diff)
downloadcpython-git-8b4367ec10c0518b06a8291f4313ef7677d85988.tar.gz
#4877: Fix a segfault in xml.parsers.expat while attempting to parse a closed file.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_pyexpat.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_pyexpat.py b/Lib/test/test_pyexpat.py
index 840a7a8355..75b031ac17 100644
--- a/Lib/test/test_pyexpat.py
+++ b/Lib/test/test_pyexpat.py
@@ -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):