We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
as_string()
dumps()
The .as_string() should return '["\\\\"]' not '["\\"]', i.e. the on-file document should look like
.as_string()
'["\\\\"]'
'["\\"]'
["\\"]
not
["\"]
reproduction script:
import tomlkit tomlkit.__version__ # '0.11.5' doc = tomlkit.TOMLDocument() doc.add("\\", tomlkit.table()) # {'\\': {}} doc.as_string() # '["\\"]\n' print(doc.as_string()) tomlkit.loads(doc.as_string()) # error! tomlkit.loads('["\\\\"]\n') # {'\\': {}}
interpreter trace:
>>> tomlkit.__version__ '0.11.5' >>> doc = tomlkit.TOMLDocument() >>> doc.add("\\", tomlkit.table()) {'\\': {}} >>> doc.as_string() '["\\"]\n' >>> print(doc.as_string()) ["\"] >>> tomlkit.loads(doc.as_string()) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "[...]/tomlkit-repro.py", line 7, in <module> File "[...]/.venv/lib/python3.8/site-packages/tomlkit/api.py", line 42, in loads return parse(string) File "[...]/.venv/lib/python3.8/site-packages/tomlkit/api.py", line 82, in parse return Parser(string).parse() File "[...]/.venv/lib/python3.8/site-packages/tomlkit/parser.py", line 158, in parse key, value = self._parse_table() File "[...]/.venv/lib/python3.8/site-packages/tomlkit/parser.py", line 906, in _parse_table key = self._parse_key() File "[...]/.venv/lib/python3.8/site-packages/tomlkit/parser.py", line 362, in _parse_key return self._parse_quoted_key() File "[...]/.venv/lib/python3.8/site-packages/tomlkit/parser.py", line 378, in _parse_quoted_key key_str = self._parse_string( File "[...]/.venv/lib/python3.8/site-packages/tomlkit/parser.py", line 825, in _parse_string raise self.parse_error(InvalidControlChar, code, "strings") tomlkit.exceptions.InvalidControlChar: Control characters (codes less than 0x1f and 0x7f) are not allowed in strings, use \u000a instead at line 1 col 5 >>> tomlkit.loads('["\\\\"]\n') {'\\': {}}
The text was updated successfully, but these errors were encountered:
b277474
fix: escape backslashes in basic strings
83d9edb
Resolve python-poetry#245
No branches or pull requests
The
.as_string()
should return'["\\\\"]'
not'["\\"]'
, i.e. the on-file document should look like["\\"]
not
["\"]
reproduction script:
interpreter trace:
The text was updated successfully, but these errors were encountered: