Skip to content

Commit

Permalink
Fix null reference for syntax errors due to invalid encodings (Pyflak…
Browse files Browse the repository at this point in the history
…es) (#433)
  • Loading branch information
smacke authored Sep 7, 2023
1 parent 3f08d8c commit e5c913d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pylsp/plugins/pyflakes_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ def syntaxError(self, _filename, msg, lineno, offset, text):
# We've seen that lineno and offset can sometimes be None
lineno = lineno or 1
offset = offset or 0
# could be None if the error is due to an invalid encoding
# see e.g. https://github.com/python-lsp/python-lsp-server/issues/429
text = text or ""

err_range = {
"start": {"line": lineno - 1, "character": offset},
Expand Down

0 comments on commit e5c913d

Please sign in to comment.