Skip to content

Commit 836631f

Browse files
authored
fix error reporter and testsuite in 3.11.4+ (#775)
1 parent f2671ff commit 836631f

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

pyflakes/reporter.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,9 @@ def syntaxError(self, filename, msg, lineno, offset, text):
5656
else:
5757
line = text.splitlines()[-1]
5858

59+
# lineno might be None if the error was during tokenization
5960
# lineno might be 0 if the error came from stdin
60-
lineno = max(lineno, 1)
61+
lineno = max(lineno or 0, 1)
6162

6263
if offset is not None:
6364
# some versions of python emit an offset of -1 for certain encoding errors

pyflakes/test/test_api.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -621,8 +621,12 @@ def test_misencodedFileUTF16(self):
621621
x = "%s"
622622
""" % SNOWMAN).encode('utf-16')
623623
with self.makeTempFile(source) as sourcePath:
624-
self.assertHasErrors(
625-
sourcePath, [f"{sourcePath}: problem decoding source\n"])
624+
if sys.version_info < (3, 11, 4):
625+
expected = f"{sourcePath}: problem decoding source\n"
626+
else:
627+
expected = f"{sourcePath}:1: source code string cannot contain null bytes\n" # noqa: E501
628+
629+
self.assertHasErrors(sourcePath, [expected])
626630

627631
def test_checkRecursive(self):
628632
"""

0 commit comments

Comments
 (0)