From 9f7d71aa8fb5ab0192fdf0b2f22aebcf81e88738 Mon Sep 17 00:00:00 2001 From: Philip Douglass Date: Sun, 24 Jan 2016 20:21:55 -0500 Subject: [PATCH 1/2] Expand vars and user tilde for upgrade backup --- jrnl/upgrade.py | 1 + 1 file changed, 1 insertion(+) diff --git a/jrnl/upgrade.py b/jrnl/upgrade.py index 88c9545a..c5979c9f 100644 --- a/jrnl/upgrade.py +++ b/jrnl/upgrade.py @@ -10,6 +10,7 @@ import os def backup(filename, binary=False): util.prompt(" Created a backup at {}.backup".format(filename)) + filename = os.path.expanduser(os.path.expandvars(filename)) with open(filename, 'rb' if binary else 'r') as original: contents = original.read() with open(filename + ".backup", 'wb' if binary else 'w') as backup: From 04082d36c9d1e8cf08604dabe33a7b932b90db7d Mon Sep 17 00:00:00 2001 From: Philip Douglass Date: Sun, 24 Jan 2016 21:16:50 -0500 Subject: [PATCH 2/2] Open config_path as utf-8 --- jrnl/upgrade.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jrnl/upgrade.py b/jrnl/upgrade.py index c5979c9f..3784c9f6 100644 --- a/jrnl/upgrade.py +++ b/jrnl/upgrade.py @@ -6,6 +6,7 @@ from . import util from .EncryptedJournal import EncryptedJournal import sys import os +import codecs def backup(filename, binary=False): @@ -18,7 +19,7 @@ def backup(filename, binary=False): def upgrade_jrnl_if_necessary(config_path): - with open(config_path) as f: + with codecs.open(config_path, "r", "utf-8") as f: config_file = f.read() if not config_file.strip().startswith("{"): return