7519: GRAMPs unable to handle ... Path with accented characters
Much worse, actually. Gramps wasn't able to handle any non-ascii
characters in any preference setting from Python2.
repr() in Py2 effectively runs "encode(val, ascii, backslashreplace)"
on its argument, and there's no way to reconstruct the string.
(cherry picked from commit 8cbb3ef014
)
This commit is contained in:
parent
3a56ed8433
commit
3535f7a79f
@ -50,7 +50,11 @@ _ = glocale.translation.gettext
|
||||
|
||||
def safe_eval(exp):
|
||||
# restrict eval to empty environment
|
||||
try:
|
||||
return eval(exp, {})
|
||||
except SyntaxError:
|
||||
logging.warning ("Invalid command string: %s", exp)
|
||||
return exp
|
||||
|
||||
##try:
|
||||
## from ast import literal_eval as safe_eval
|
||||
@ -364,8 +368,16 @@ class ConfigManager(object):
|
||||
default = ""
|
||||
if isinstance(value, int):
|
||||
value = int(value)
|
||||
key_file.write(("%s%s=%s\n")% (default,
|
||||
key,
|
||||
# repr() in Py2 effectively runs "encode(val,
|
||||
# ascii, backslashreplace)" on its argument,
|
||||
# and there's no way to reconstruct the
|
||||
# string, so we special-case handling writing
|
||||
# to ensure the unicode is preserved.
|
||||
if isinstance(value, str) or isinstance(value, unicode):
|
||||
key_file.write(("%s%s=u'%s'\n") % (default, key,
|
||||
value))
|
||||
else:
|
||||
key_file.write(("%s%s=%s\n")% (default, key,
|
||||
repr(value)))
|
||||
key_file.write("\n")
|
||||
key_file.close()
|
||||
|
Loading…
Reference in New Issue
Block a user