Skip to content

Commit e5c913d

Browse files
authored
Fix null reference for syntax errors due to invalid encodings (Pyflakes) (#433)
1 parent 3f08d8c commit e5c913d

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

pylsp/plugins/pyflakes_lint.py

+3
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ def syntaxError(self, _filename, msg, lineno, offset, text):
5252
# We've seen that lineno and offset can sometimes be None
5353
lineno = lineno or 1
5454
offset = offset or 0
55+
# could be None if the error is due to an invalid encoding
56+
# see e.g. https://github.com/python-lsp/python-lsp-server/issues/429
57+
text = text or ""
5558

5659
err_range = {
5760
"start": {"line": lineno - 1, "character": offset},

0 commit comments

Comments
 (0)