From 9fcaa48cbed9c7e4b8f4e4d838188291238e0627 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=83=C2=B6rgen=20Stenarson?= Date: Wed, 27 Mar 2013 22:00:34 +0100 Subject: [PATCH] Handle non-ascii for history and ini filenames --- pyreadline/lineeditor/history.py | 2 +- pyreadline/rlmain.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pyreadline/lineeditor/history.py b/pyreadline/lineeditor/history.py index 1730cce..ab46c44 100644 --- a/pyreadline/lineeditor/history.py +++ b/pyreadline/lineeditor/history.py @@ -27,7 +27,7 @@ class LineHistory(object): self.history = [] self._history_length = 100 self._history_cursor = 0 - self.history_filename = os.path.expanduser('~/.history') #Cannot expand unicode strings correctly on python2.4 + self.history_filename = os.path.expanduser(ensure_str('~/.history')) #Cannot expand unicode strings correctly on python2.4 self.lastcommand = None self.query = "" self.last_search_for = "" diff --git a/pyreadline/rlmain.py b/pyreadline/rlmain.py index bacce28..430efba 100644 --- a/pyreadline/rlmain.py +++ b/pyreadline/rlmain.py @@ -21,7 +21,7 @@ import pyreadline.console as console import pyreadline.logger as logger from pyreadline.keysyms.common import make_KeyPress_from_keydescr -from pyreadline.unicode_helper import ensure_unicode +from pyreadline.unicode_helper import ensure_unicode, ensure_str from .logger import log from .modes import editingmodes from .error import ReadlineError, GetSetError @@ -278,7 +278,7 @@ class BaseReadline(object): self.callback(line) def read_inputrc(self, #in 2.4 we cannot call expanduser with unicode string - inputrcpath=os.path.expanduser("~/pyreadlineconfig.ini")): + inputrcpath=os.path.expanduser(ensure_str("~/pyreadlineconfig.ini"))): modes = dict([(x.mode,x) for x in self.editingmodes]) mode = self.editingmodes[0].mode @@ -312,7 +312,7 @@ class BaseReadline(object): pyreadline.lineeditor.lineobj.kill_ring_to_clipboard = killring def sethistoryfilename(filename): - self.mode._history.history_filename=os.path.expanduser(filename) + self.mode._history.history_filename = os.path.expanduser(ensure_str(filename)) def setbellstyle(mode): self.bell_style = mode