From 31b8caf0a2ab6c3e05db4dedc198764ad17bcd06 Mon Sep 17 00:00:00 2001 From: Alex Apolloni Date: Tue, 29 Oct 2013 16:11:42 +0100 Subject: [PATCH 1/3] file paths with a U like uses directories in Windows where being interperted at Unicode so force converting to string --- jrnl/util.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/jrnl/util.py b/jrnl/util.py index 7ae9d4df..fbba969e 100644 --- a/jrnl/util.py +++ b/jrnl/util.py @@ -54,12 +54,15 @@ def set_keychain(journal_name, password): def u(s): """Mock unicode function for python 2 and 3 compatibility.""" - return s if PY3 or type(s) is unicode else unicode(s, "unicode_escape") + """file paths with a U like uses directories in Windows where being interperted at Unicode so force converting to string""" + return s if PY3 or type(s) is unicode else unicode(s.encode('string-escape'), "unicode_escape") def prompt(msg): """Prints a message to the std err stream defined in util.""" if not msg.endswith("\n"): msg += "\n" + print "barf" + print msg STDERR.write(u(msg)) def py23_input(msg): From ecdf217d0f15b81df0a2359112e32834d314a18b Mon Sep 17 00:00:00 2001 From: Alex Apolloni Date: Tue, 29 Oct 2013 16:11:42 +0100 Subject: [PATCH 2/3] file paths with a U like uses directories in Windows where being interperted at Unicode so force converting to string. removed debug prints. --- jrnl/util.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jrnl/util.py b/jrnl/util.py index 7ae9d4df..0a92bc98 100644 --- a/jrnl/util.py +++ b/jrnl/util.py @@ -54,7 +54,8 @@ def set_keychain(journal_name, password): def u(s): """Mock unicode function for python 2 and 3 compatibility.""" - return s if PY3 or type(s) is unicode else unicode(s, "unicode_escape") + """file paths with a U like uses directories in Windows where being interperted at Unicode so force converting to string""" + return s if PY3 or type(s) is unicode else unicode(s.encode('string-escape'), "unicode_escape") def prompt(msg): """Prints a message to the std err stream defined in util.""" From fa15dccfaf8c454950e5aaf3124a0b0937e2a43a Mon Sep 17 00:00:00 2001 From: Alex Apolloni Date: Wed, 30 Oct 2013 11:12:49 +0100 Subject: [PATCH 3/3] took out debug prints --- jrnl/util.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/jrnl/util.py b/jrnl/util.py index fbba969e..0a92bc98 100644 --- a/jrnl/util.py +++ b/jrnl/util.py @@ -61,8 +61,6 @@ def prompt(msg): """Prints a message to the std err stream defined in util.""" if not msg.endswith("\n"): msg += "\n" - print "barf" - print msg STDERR.write(u(msg)) def py23_input(msg):