eric7/Plugins/CheckerPlugins/SyntaxChecker/tomlCheckSyntax.py

branch
eric7
changeset 9107
8e9525a780ae
parent 8881
54e42bc2437a
--- a/eric7/Plugins/CheckerPlugins/SyntaxChecker/tomlCheckSyntax.py	Mon May 30 09:51:57 2022 +0200
+++ b/eric7/Plugins/CheckerPlugins/SyntaxChecker/tomlCheckSyntax.py	Tue May 31 09:59:42 2022 +0200
@@ -173,19 +173,21 @@
     @rtype dict
     """
     try:
-        import toml
+        import tomlkit
+        from tomlkit.exceptions import ParseError
     except ImportError:
-        error = "toml not available. Install it via the PyPI interface."
+        error = "tomlkit not available. Install it via the PyPI interface."
         return [{'error': (file, 0, 0, '', error)}]
     
     codestring = normalizeCode(codestring)
     
     try:
-        toml.loads(codestring)
-    except toml.TomlDecodeError as exc:
-        line = exc.lineno
-        column = exc.colno
-        error = exc.msg
+        tomlkit.parse(codestring)
+    except ParseError as exc:
+        line = exc.line
+        column = exc.col
+        error = str(exc).split(" at ", 1)[0].strip()
+        # get error message without location
         
         cline = min(len(codestring.splitlines()), int(line)) - 1
         code = codestring.splitlines()[cline]

eric ide

mercurial