diff --git a/src/calibre/ebooks/oeb/base.py b/src/calibre/ebooks/oeb/base.py index cf80e4abe2..632696b4ae 100644 --- a/src/calibre/ebooks/oeb/base.py +++ b/src/calibre/ebooks/oeb/base.py @@ -25,6 +25,7 @@ from calibre.translations.dynamic import translate from calibre.ebooks.chardet import xml_to_unicode from calibre.ebooks.oeb.entitydefs import ENTITYDEFS from calibre.ebooks.conversion.preprocess import CSSPreProcessor +from calibre import isbytestring RECOVER_PARSER = etree.XMLParser(recover=True, no_network=True) @@ -404,7 +405,8 @@ class DirContainer(object): def __init__(self, path, log): self.log = log - path = unicode(path) + if isbytestring(path): + path = path.decode(filesystem_encoding) ext = os.path.splitext(path)[1].lower() if ext == '.opf': self.opfname = os.path.basename(path) diff --git a/src/calibre/ptempfile.py b/src/calibre/ptempfile.py index 0aa71770a0..71ae9b0789 100644 --- a/src/calibre/ptempfile.py +++ b/src/calibre/ptempfile.py @@ -7,8 +7,7 @@ being closed. """ import tempfile, os, atexit, binascii, cPickle -from calibre import __version__, __appname__, isbytestring -from calibre.constants import filesystem_encoding +from calibre.constants import __version__, __appname__ def cleanup(path): try: @@ -43,8 +42,6 @@ def base_dir(): _base_dir = tempfile.mkdtemp(prefix='%s_%s_tmp_'%(__appname__, __version__)) atexit.register(remove_dir, _base_dir) - if isbytestring(_base_dir): - _base_dir = _base_dir.decode(filesystem_encoding) return _base_dir class PersistentTemporaryFile(object):