Skip to content

Commit 32182c8

Browse files
committed
fixes #430
1 parent 2178878 commit 32182c8

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

deepdiff/path.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def _add_to_elements(elements, elem, inside):
2222
return
2323
if not elem.startswith('__'):
2424
remove_quotes = False
25-
if '\\' in elem:
25+
if '𝆺𝅥𝅯' in elem or '\\' in elem:
2626
remove_quotes = True
2727
else:
2828
try:
@@ -62,7 +62,7 @@ def _path_to_elements(path, root_element=DEFAULT_FIRST_ELEMENT):
6262
inside_quotes = False
6363
quote_used = ''
6464
for char in path:
65-
if prev_char == '\\':
65+
if prev_char == '𝆺𝅥𝅯':
6666
elem += char
6767
elif char in {'"', "'"}:
6868
elem += char
@@ -270,12 +270,11 @@ def parse_path(path, root_element=DEFAULT_FIRST_ELEMENT, include_actions=False):
270270
def stringify_element(param, quote_str=None):
271271
has_quote = "'" in param
272272
has_double_quote = '"' in param
273-
if has_quote and has_double_quote:
273+
if has_quote and has_double_quote and not quote_str:
274274
new_param = []
275275
for char in param:
276276
if char in {'"', "'"}:
277-
import pytest; pytest.set_trace()
278-
new_param.append('\\')
277+
new_param.append('𝆺𝅥𝅯')
279278
new_param.append(char)
280279
result = '"' + ''.join(new_param) + '"'
281280
elif has_quote:

tests/test_diff_text.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ def test_diff_quote_and_double_quote_in_string(self):
312312
t1 = {'''a'"a''': 1}
313313
t2 = {'''a'"a''': 2}
314314
diff = DeepDiff(t1, t2)
315-
expected = {'values_changed': {"root['a\\'\\\"a']": {'new_value': 2, 'old_value': 1}}}
315+
expected = {'values_changed': {'root["a\'"a"]': {'new_value': 2, 'old_value': 1}}}
316316
assert expected == diff
317317

318318
def test_bytes(self):

0 commit comments

Comments
 (0)