From d737564887fd1603c89a045e7b985b765c16d2d6 Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Fri, 24 Jun 2022 19:47:33 +0200 Subject: pyGHDL/lsp: load files as bytes string --- pyGHDL/lsp/workspace.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'pyGHDL/lsp/workspace.py') diff --git a/pyGHDL/lsp/workspace.py b/pyGHDL/lsp/workspace.py index 54fa17ce6..3b75a6493 100644 --- a/pyGHDL/lsp/workspace.py +++ b/pyGHDL/lsp/workspace.py @@ -96,7 +96,9 @@ class Workspace(object): # We assume the path is correct. path = lsp.path_from_uri(doc_uri) if source is None: - source = open(path).read() + source = open(path, "rb").read() + else: + source = source.encode(document.Document.encoding, "replace") sfe = document.Document.load(source, os.path.dirname(path), os.path.basename(path)) return self._create_document(doc_uri, sfe) @@ -152,7 +154,7 @@ class Workspace(object): absname = os.path.join(self._root_path, name) # Create a document for this file. try: - fd = open(absname) + fd = open(absname, "rb") sfe = document.Document.load(fd.read(), self._root_path, name) fd.close() except OSError as err: -- cgit v1.2.3