Skip to content

Commit

Permalink
fix error reporter and testsuite in 3.11.4+ (#775)
Browse files Browse the repository at this point in the history
  • Loading branch information
asottile authored Jun 13, 2023
1 parent f2671ff commit 836631f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion pyflakes/reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ def syntaxError(self, filename, msg, lineno, offset, text):
else:
line = text.splitlines()[-1]

# lineno might be None if the error was during tokenization
# lineno might be 0 if the error came from stdin
lineno = max(lineno, 1)
lineno = max(lineno or 0, 1)

if offset is not None:
# some versions of python emit an offset of -1 for certain encoding errors
Expand Down
8 changes: 6 additions & 2 deletions pyflakes/test/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,8 +621,12 @@ def test_misencodedFileUTF16(self):
x = "%s"
""" % SNOWMAN).encode('utf-16')
with self.makeTempFile(source) as sourcePath:
self.assertHasErrors(
sourcePath, [f"{sourcePath}: problem decoding source\n"])
if sys.version_info < (3, 11, 4):
expected = f"{sourcePath}: problem decoding source\n"
else:
expected = f"{sourcePath}:1: source code string cannot contain null bytes\n" # noqa: E501

self.assertHasErrors(sourcePath, [expected])

def test_checkRecursive(self):
"""
Expand Down

0 comments on commit 836631f

Please sign in to comment.