diff --git a/CHANGELOG.md b/CHANGELOG.md index 43c02af8..e43f5c7a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ Changelog ### 1.7 (December 22, 2013) -* __1.7.7__ Cleaned up imporrts +* __1.7.7__ Cleaned up imports, better unicode support * __1.7.6__ Python 3 port for slugify * __1.7.5__ Colorama is only needed on windows. Smaller fixes * __1.7.3__ Touches temporary files before opening them to allow more external editors. diff --git a/features/steps/core.py b/features/steps/core.py index 2a27ebc9..6f2baa5b 100644 --- a/features/steps/core.py +++ b/features/steps/core.py @@ -129,11 +129,15 @@ def check_output_time_inline(context, text): @then('the output should contain "{text}"') def check_output_inline(context, text): out = context.stdout_capture.getvalue() + if isinstance(out, bytes): + out = out.decode('utf-8') assert text in out @then('the output should not contain "{text}"') def check_output_not_inline(context, text): out = context.stdout_capture.getvalue() + if isinstance(out, bytes): + out = out.decode('utf-8') assert text not in out @then('we should see the message "{text}"') diff --git a/jrnl/cli.py b/jrnl/cli.py index d6156822..7a9c1b55 100644 --- a/jrnl/cli.py +++ b/jrnl/cli.py @@ -115,7 +115,8 @@ def run(manual_args=None): args = parse_args(manual_args) if args.version: - print("{0} version {1}".format(jrnl.__title__, jrnl.__version__)) + version_str = "{0} version {1}".format(jrnl.__title__, jrnl.__version__) + print(util.py2encode(version_str)) sys.exit(0) # If the first textual argument points to a journal file, @@ -181,17 +182,17 @@ def run(manual_args=None): # Reading mode if not mode_compose and not mode_export: - print(journal.pprint()) + print(util.py2encode(journal.pprint())) # Various export modes elif args.short: - print(journal.pprint(short=True)) + print(util.py2encode(journal.pprint(short=True))) elif args.tags: - print(exporters.to_tag_list(journal)) + print(util.py2encode(exporters.to_tag_list(journal))) elif args.export is not False: - print(exporters.export(journal, args.export, args.output)) + print(util.py2encode(exporters.export(journal, args.export, args.output))) elif (args.encrypt is not False or args.decrypt is not False) and not PYCRYPTO: util.prompt("PyCrypto not found. To encrypt or decrypt your journal, install the PyCrypto package from http://www.pycrypto.org.") diff --git a/jrnl/util.py b/jrnl/util.py index 72d00ca3..708150f0 100644 --- a/jrnl/util.py +++ b/jrnl/util.py @@ -65,6 +65,10 @@ def u(s): """Mock unicode function for python 2 and 3 compatibility.""" return s if PY3 or type(s) is unicode else unicode(s.encode('string-escape'), "unicode_escape") +def py2encode(s): + """Encode in Python 2, but not in python 3.""" + return s.encode("utf-8") if PY2 and type(s) is unicode else s + def prompt(msg): """Prints a message to the std err stream defined in util.""" if not msg.endswith("\n"):