From 308aa49ba6dabcb413289f198ffc19cffa0c575b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ozan=20=C3=87a=C4=9Flayan?= Date: Thu, 11 Feb 2010 21:07:01 +0000 Subject: [PATCH] Real fix for #6748: The exception is raised both in getcwd() and chdir() BUG:COMMENT:6748 --- NEWS | 4 ++++ pisi/archive.py | 13 +++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index e69de29b..6acf98c2 100644 --- a/NEWS +++ b/NEWS @@ -0,0 +1,4 @@ +pisi 2.2.19 (??/02/2010) +------------------------- + +#6748 - pisi fails to install a package when CWD doesn't exist anymore (real fix) diff --git a/pisi/archive.py b/pisi/archive.py index f08232b7..847c5bfb 100644 --- a/pisi/archive.py +++ b/pisi/archive.py @@ -13,7 +13,6 @@ """Archive module provides access to regular archive file types.""" # standard library modules -import exceptions import os import stat import shutil @@ -153,7 +152,12 @@ class ArchiveTar(ArchiveBase): raise UnknownArchiveType self.tar = tarfile.open(self.file_path, rmode) - oldwd = os.getcwd() + oldwd = None + try: + # Don't fail if CWD doesn't exist (#6748) + oldwd = os.getcwd() + except OSError: + pass os.chdir(target_dir) uid = os.getuid() @@ -203,9 +207,10 @@ class ArchiveTar(ArchiveBase): os.unlink(self.file_path) try: - os.chdir(oldwd) + if oldwd: + os.chdir(oldwd) # Bug #6748 - except exceptions.OSError: + except OSError: pass self.close()