Skip to content

Commit

Permalink
test_pickle_exception: even harder location stripping. Ref ionelmc#74.
Browse files Browse the repository at this point in the history
With Python 3.13, we need to strip even harder, because we get
location lines with differing amounts of tildes and up carets in
them, e.g.:

    ~~^~~~~

and:

    ^^^^^^^

Let's ditch the regex and instead go line-by-line with a pretty
loose match for anything that looks like a location line.

Signed-off-by: Adam Williamson <[email protected]>
  • Loading branch information
AdamWill committed Jun 18, 2024
1 parent 9f6f864 commit 1132960
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tests/test_pickle_exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ class CustomError(Exception):


def strip_locations(tb_text):
return tb_text.replace(' ~~^~~\n', '').replace(' ^^^^^^^^^^^^^^^^^\n', '')
lines = tb_text.splitlines()
lines = [line for line in lines if '~~^~~' not in line and '^^^^' not in line]
return '\n'.join(lines)


@pytest.mark.parametrize('protocol', [None, *list(range(1, pickle.HIGHEST_PROTOCOL + 1))])
Expand Down

0 comments on commit 1132960

Please sign in to comment.