summaryrefslogtreecommitdiff
path: root/tests/test_parser.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2022-08-21 09:35:30 -0400
committerNed Batchelder <ned@nedbatchelder.com>2022-08-21 09:43:27 -0400
commit3703bae58b53efec3314bc07b9de157049ad8b70 (patch)
tree58d7b2b6d1bbd8f56a7576bd5971a0051db52ef8 /tests/test_parser.py
parent816acad2de49e82e3903f4736d611e715a0b5780 (diff)
downloadpython-coveragepy-git-3703bae58b53efec3314bc07b9de157049ad8b70.tar.gz
fix: don't cache a failed parse
Found by OSS-Fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=50381
Diffstat (limited to 'tests/test_parser.py')
-rw-r--r--tests/test_parser.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/test_parser.py b/tests/test_parser.py
index a20741ad..48f5ade3 100644
--- a/tests/test_parser.py
+++ b/tests/test_parser.py
@@ -247,6 +247,15 @@ class PythonParserTest(CoverageTest):
assert expected_arcs == parser.arcs()
assert expected_exits == parser.exit_counts()
+ def test_fuzzed_double_parse(self):
+ # https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=50381
+ # The second parse used to raise `TypeError: 'NoneType' object is not iterable`
+ msg = "EOF in multi-line statement"
+ with pytest.raises(NotPython, match=msg):
+ self.parse_source("]")
+ with pytest.raises(NotPython, match=msg):
+ self.parse_source("]")
+
class ParserMissingArcDescriptionTest(CoverageTest):
"""Tests for PythonParser.missing_arc_description."""