From 34523ac958e82cac5a8dec412f0f442385d35559 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 7 Apr 2012 18:56:16 +0530 Subject: [PATCH] ... --- src/calibre/ebooks/oeb/base.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/calibre/ebooks/oeb/base.py b/src/calibre/ebooks/oeb/base.py index bf9287d53a..3b8d13fb3f 100644 --- a/src/calibre/ebooks/oeb/base.py +++ b/src/calibre/ebooks/oeb/base.py @@ -454,7 +454,14 @@ class DirContainer(object): path = os.path.join(self.rootdir, self._unquote(path)) except ValueError: #Happens if path contains quoted special chars return False - return os.path.isfile(path) + try: + return os.path.isfile(path) + except UnicodeEncodeError: + # On linux, if LANG is unset, the os.stat call tries to encode the + # unicode path using ASCII + # To replicate try: + # LANG=en_US.ASCII python -c "import os; os.stat('Espa\xf1a')" + return os.path.isfile(path.encode(filesystem_encoding)) def namelist(self): names = []