-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
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
Wrong control characters escaping #209
Comments
Python string literals interpret the |
I cannot agree with you.
You can easily see that the serialized version must be exactly the same as Python non-raw representation. |
In the |
There are more observations. Every character in the range U+0000 ... U+001F must be escaped like "\u0000" ... "\u001f" except the mentioned special cases that may be escaped in the short form like "\n". The test # -*- encoding: utf-8 -*-
from pyhocon import ConfigTree
from pyhocon.converter import HOCONConverter
def to_hocon(obj):
return HOCONConverter.to_hocon(ConfigTree(obj), compact=True)
class TestConverter(object):
def test_escape_control_characters(self):
assert r'a = "\u0000"' == to_hocon({'a': '\x00'}) fails
|
Fix JSON and HOCON string escaping (#209)
Action. Save a configuration with a sting containing
'\\r'
or'\\n'
.Expected result. The saved configuration contains strings with
'\\r'
or'\\n'
.Actual result. The saved configuration contains strings with
'\r'
or'\n'
instead.Details.
Save a configuration.
The result is as expected.
Now save a configuration with a string containing
'\\r'
.Expected
c:\\result\\dir
.Save a configuration with a string containing
'\\n'
.Expected
c:\\next\\dir
.The text was updated successfully, but these errors were encountered: