From fc0bbaf7968b30ec898dd63b7649901abad97901 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 22 Feb 2012 13:57:52 +0530 Subject: [PATCH] ... --- src/calibre/ptempfile.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/calibre/ptempfile.py b/src/calibre/ptempfile.py index ca6c9646c5..48974b0c6c 100644 --- a/src/calibre/ptempfile.py +++ b/src/calibre/ptempfile.py @@ -65,10 +65,12 @@ def base_dir(): _base_dir = tempfile.mkdtemp(prefix=prefix, dir=base) atexit.register(remove_dir, _base_dir) - # Tell the tempfile module to in future always use our temp dir - # This also means that it will return unicode paths, instead of - # bytestrings. This is particularly important on windows. - tempfile.tempdir = _base_dir + try: + tempfile.gettempdir() + except: + # Widows temp vars set to a path not encodable in mbcs + # Use our temp dir + tempfile.tempdir = _base_dir return _base_dir