diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..4bd07ef --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,12 @@ +{ + "python.testing.unittestArgs": [ + "-v", + "-s", + "./tests", + "-p", + "test_*.py" + ], + "python.testing.pytestEnabled": true, + "python.testing.nosetestsEnabled": false, + "python.testing.unittestEnabled": false +} \ No newline at end of file diff --git a/tests/test_api.py b/tests/test_api.py index 1acc26f..84dae75 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -16,6 +16,13 @@ TEST_DICT = {"a": {"b": 1, "c": 2}} +def test_bug_368(): + data = toml.loads(toml.dumps({"a": "\""})) + assert "\"" == data["a"] + +def test_bug_368Bis(): + data = toml.loads(toml.dumps({"a": ''})) + assert '' == data["a"] def test_bug_148(): assert 'a = "\\u0064"\n' == toml.dumps({'a': '\\x64'}) diff --git a/toml/decoder.py b/toml/decoder.py index bf400e9..0cb393f 100644 --- a/toml/decoder.py +++ b/toml/decoder.py @@ -872,9 +872,7 @@ def load_value(self, v, strictly_valid=True): v = _load_unicode_escapes(hexbytes[0], hexbytes[1:], prefix) v = _unescape(v) - if len(v) > 1 and v[1] == quotechar and (len(v) < 3 or - v[1] == v[2]): - v = v[2:-2] + return (v[1:-1], "str") elif v[0] == '[': return (self.load_array(v), "array")