Skip to content

Commit

Permalink
fix: another possible assert changed back to a conditional.
Browse files Browse the repository at this point in the history
  • Loading branch information
nedbat committed Nov 15, 2024
1 parent 42961d6 commit 898e94a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ upgrading your version of coverage.py.
Unreleased
----------

Nothing yet.
- fix: ugh, the other assert from 7.6.5 can also be encountered in the wild,
so it's been restored to a conditional. Sorry for the churn.


.. start-releases
Expand Down
4 changes: 2 additions & 2 deletions coverage/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,8 +444,8 @@ def _line_numbers(self) -> Iterable[TLineNo]:
if line_incr >= 0x80:
line_incr -= 0x100
line_num += line_incr
assert line_num != last_line_num, f"Oops: {self.code.co_name}@{line_num}"
yield line_num
if line_num != last_line_num:
yield line_num

def _find_statements(self) -> Iterable[TLineNo]:
"""Find the statements in `self.code`.
Expand Down
12 changes: 10 additions & 2 deletions tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,14 +198,22 @@ def test_fuzzed_double_parse(self) -> None:
self.parse_text("]")

def test_bug_1891(self) -> None:
# This code exercises a code path I thought was impossible.
# These examples exercise code paths I thought were impossible.
parser = self.parse_text("""\
res = siblings(
'configure',
**ca,
)
""")
assert parser.exit_counts() == { 1:1 }
assert parser.exit_counts() == {1: 1}
parser = self.parse_text("""\
def g2():
try:
return 2
finally:
return 3
""")
assert parser.exit_counts() == {1: 1, 2: 1, 3: 1, 5: 1}


class ExclusionParserTest(PythonParserTestBase):
Expand Down

0 comments on commit 898e94a

Please sign in to comment.