summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_xml_etree_c.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-01-04 02:07:34 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-01-04 02:07:34 (GMT)
commitb3c9e073fc7b93529ceb0af520d148385e6f63f7 (patch)
tree77b8ef468c87c3258cd734fc2c438f57a71d0d65 /Lib/test/test_xml_etree_c.py
parente6edec23718072ed7903be9dae37ae330a9d81d5 (diff)
downloadcpython-b3c9e073fc7b93529ceb0af520d148385e6f63f7.zip
cpython-b3c9e073fc7b93529ceb0af520d148385e6f63f7.tar.gz
cpython-b3c9e073fc7b93529ceb0af520d148385e6f63f7.tar.bz2
Issue #8651: PyArg_Parse*() functions raise an OverflowError if the file
doesn't have PY_SSIZE_T_CLEAN define and the size doesn't fit in an int (length bigger than 2^31-1).
Diffstat (limited to 'Lib/test/test_xml_etree_c.py')
-rw-r--r--Lib/test/test_xml_etree_c.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_xml_etree_c.py b/Lib/test/test_xml_etree_c.py
index 5c0bf6c..db69e5f 100644
--- a/Lib/test/test_xml_etree_c.py
+++ b/Lib/test/test_xml_etree_c.py
@@ -1,6 +1,8 @@
# xml.etree test for cElementTree
from test import support
+from test.support import precisionbigmemtest, _2G
+import unittest
cET = support.import_module('xml.etree.cElementTree')
@@ -31,12 +33,28 @@ def sanity():
"""
+class MiscTests(unittest.TestCase):
+ # Issue #8651.
+ @support.precisionbigmemtest(size=support._2G + 100, memuse=1)
+ def test_length_overflow(self, size):
+ if size < support._2G + 100:
+ self.skipTest("not enough free memory, need at least 2 GB")
+ data = b'x' * size
+ parser = cET.XMLParser()
+ try:
+ self.assertRaises(OverflowError, parser.feed, data)
+ finally:
+ data = None
+
+
def test_main():
from test import test_xml_etree, test_xml_etree_c
# Run the tests specific to the C implementation
support.run_doctest(test_xml_etree_c, verbosity=True)
+ support.run_unittest(MiscTests)
+
# Assign the C implementation before running the doctests
# Patch the __name__, to prevent confusion with the pure Python test
pyET = test_xml_etree.ET