mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-09 04:18:56 +02:00
...
This commit is contained in:
parent
bf098af98b
commit
40ac4f8a7a
1 changed files with 12 additions and 1 deletions
|
|
@ -72,8 +72,19 @@ def __init__(self, suffix="", prefix="", dir=None, mode='w+b'):
|
|||
prefix = ""
|
||||
if dir is None:
|
||||
dir = base_dir()
|
||||
fd, name = tempfile.mkstemp(suffix, __appname__+"_"+ __version__+"_" + prefix,
|
||||
try:
|
||||
fd, name = tempfile.mkstemp(suffix, __appname__+"_"+ __version__+"_" + prefix,
|
||||
dir=dir)
|
||||
except UnicodeDecodeError:
|
||||
global _base_dir
|
||||
from calibre.constants import filesystem_encoding
|
||||
base_dir()
|
||||
if not isinstance(_base_dir, unicode):
|
||||
_base_dir = _base_dir.decode(filesystem_encoding)
|
||||
dir = dir.decode(filesystem_encoding)
|
||||
fd, name = tempfile.mkstemp(suffix, __appname__+"_"+ __version__+"_" + prefix,
|
||||
dir=dir)
|
||||
|
||||
self._file = os.fdopen(fd, mode)
|
||||
self._name = name
|
||||
self._fd = fd
|
||||
|
|
|
|||
Loading…
Reference in a new issue