From b76159f31cf2b45fd4a75c65ec8f1cd6627a422e Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 25 Apr 2011 15:06:06 -0600 Subject: [PATCH] CurrentDir context now ignores the case when the original working dir no longer exists --- src/calibre/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/calibre/__init__.py b/src/calibre/__init__.py index 29c69a6799..bc99947345 100644 --- a/src/calibre/__init__.py +++ b/src/calibre/__init__.py @@ -388,7 +388,11 @@ class CurrentDir(object): return self.cwd def __exit__(self, *args): - os.chdir(self.cwd) + try: + os.chdir(self.cwd) + except: + # The previous CWD no longer exists + pass class StreamReadWrapper(object):