summaryrefslogtreecommitdiffstats
path: root/Lib/tkinter
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2018-06-30 06:20:28 (GMT)
committerGitHub <noreply@github.com>2018-06-30 06:20:28 (GMT)
commit5bb5bbfca847524bab5f2368bdb48eedf5dba74f (patch)
tree7f7ba4d92c8cde6f61152b7168bb61afb41b7077 /Lib/tkinter
parentf874bd1f0630644f3e3faaa2d51e6749465c70bd (diff)
downloadcpython-5bb5bbfca847524bab5f2368bdb48eedf5dba74f.zip
cpython-5bb5bbfca847524bab5f2368bdb48eedf5dba74f.tar.gz
cpython-5bb5bbfca847524bab5f2368bdb48eedf5dba74f.tar.bz2
bpo-33974: Fix passing special characters to ttk widgets. (GH-7986)
Fix passing lists and tuples of strings containing special characters '"', '\\', '{', '}' and '\n' as options to tkinter.ttk widgets.
Diffstat (limited to 'Lib/tkinter')
-rw-r--r--Lib/tkinter/__init__.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/tkinter/__init__.py b/Lib/tkinter/__init__.py
index b78191e..ff85f83 100644
--- a/Lib/tkinter/__init__.py
+++ b/Lib/tkinter/__init__.py
@@ -61,7 +61,7 @@ def _stringify(value):
if isinstance(value, (list, tuple)):
if len(value) == 1:
value = _stringify(value[0])
- if value[0] == '{':
+ if _magic_re.search(value):
value = '{%s}' % value
else:
value = '{%s}' % _join(value)
@@ -72,7 +72,10 @@ def _stringify(value):
elif _magic_re.search(value):
# add '\' before special characters and spaces
value = _magic_re.sub(r'\\\1', value)
+ value = value.replace('\n', r'\n')
value = _space_re.sub(r'\\\1', value)
+ if value[0] == '"':
+ value = '\\' + value
elif value[0] == '"' or _space_re.search(value):
value = '{%s}' % value
return value