7519: GRAMPs unable to handle ... Path with accented characters
This replaces commit 8cbb3ef014
with
removing the incorrect encoding of paths with the system filesystem
encoding. Python is mostly smart enough to do that itself.
Thanks to Paul Franklin and Josip Pisoj for their help with sorting this
out.
This commit is contained in:
parent
946c5539af
commit
a030c20210
@ -480,8 +480,6 @@ def find_next_db_dir():
|
|||||||
while True:
|
while True:
|
||||||
base = "%x" % int(time.time())
|
base = "%x" % int(time.time())
|
||||||
dbdir = os.path.expanduser(config.get('behavior.database-path'))
|
dbdir = os.path.expanduser(config.get('behavior.database-path'))
|
||||||
if sys.version_info[0] < 3:
|
|
||||||
dbdir = dbdir.encode(glocale.getfilesystemencoding())
|
|
||||||
new_path = os.path.join(dbdir, base)
|
new_path = os.path.join(dbdir, base)
|
||||||
if not os.path.isdir(new_path):
|
if not os.path.isdir(new_path):
|
||||||
break
|
break
|
||||||
|
@ -936,10 +936,6 @@ class GVPdfGvDoc(GVDocBase):
|
|||||||
dotfile = os.fdopen(handle, "wb")
|
dotfile = os.fdopen(handle, "wb")
|
||||||
dotfile.write(self._dot.getvalue())
|
dotfile.write(self._dot.getvalue())
|
||||||
dotfile.close()
|
dotfile.close()
|
||||||
# Convert filename to str using file system encoding.
|
|
||||||
if sys.version_info[0] < 3:
|
|
||||||
fname = self._filename.encode(glocale.getfilesystemencoding())
|
|
||||||
else:
|
|
||||||
fname = self._filename
|
fname = self._filename
|
||||||
|
|
||||||
# Generate the PDF file.
|
# Generate the PDF file.
|
||||||
|
@ -50,11 +50,7 @@ _ = glocale.translation.gettext
|
|||||||
|
|
||||||
def safe_eval(exp):
|
def safe_eval(exp):
|
||||||
# restrict eval to empty environment
|
# restrict eval to empty environment
|
||||||
try:
|
|
||||||
return eval(exp, {})
|
return eval(exp, {})
|
||||||
except SyntaxError:
|
|
||||||
logging.warning ("Invalid command string: %s", exp)
|
|
||||||
return exp
|
|
||||||
|
|
||||||
##try:
|
##try:
|
||||||
## from ast import literal_eval as safe_eval
|
## from ast import literal_eval as safe_eval
|
||||||
@ -372,16 +368,8 @@ class ConfigManager(object):
|
|||||||
default = ""
|
default = ""
|
||||||
if isinstance(value, int):
|
if isinstance(value, int):
|
||||||
value = int(value)
|
value = int(value)
|
||||||
# repr() in Py2 effectively runs "encode(val,
|
key_file.write(("%s%s=%s\n")% (default,
|
||||||
# ascii, backslashreplace)" on its argument,
|
key,
|
||||||
# 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)))
|
repr(value)))
|
||||||
key_file.write("\n")
|
key_file.write("\n")
|
||||||
key_file.close()
|
key_file.close()
|
||||||
|
@ -1100,8 +1100,6 @@ class ViewManager(CLIManager):
|
|||||||
value = dialog.run()
|
value = dialog.run()
|
||||||
if value:
|
if value:
|
||||||
(filename, title) = value
|
(filename, title) = value
|
||||||
if sys.version_info[0] < 3:
|
|
||||||
filename = filename.encode(glocale.getfilesystemencoding())
|
|
||||||
self.db_loader.read_file(filename)
|
self.db_loader.read_file(filename)
|
||||||
self._post_load_newdb(filename, 'x-directory/normal', title)
|
self._post_load_newdb(filename, 'x-directory/normal', title)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user