From 82839557655ce6b991dcf5198df89bcbb568e0fc Mon Sep 17 00:00:00 2001 From: Nick Bolton Date: Wed, 19 Mar 2014 14:21:12 +0000 Subject: [PATCH] fixed: ZipFile.extractall is buggy in python 2.6.1 --- ext/toolchain/commands1.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/ext/toolchain/commands1.py b/ext/toolchain/commands1.py index 7b507b79..9ff50f48 100644 --- a/ext/toolchain/commands1.py +++ b/ext/toolchain/commands1.py @@ -328,10 +328,10 @@ class InternalCommands: raise Exception('Crypto++ zip not found at: ' + zipFilename) if not os.path.exists(dir): - os.mkdir(dir) + os.mkdir(dir) zip = zipfile.ZipFile(zipFilename) - zip.extractall(dir) + self.zipExtractAll(zip, dir) def checkGTest(self): @@ -344,10 +344,10 @@ class InternalCommands: raise Exception('GTest zip not found at: ' + zipFilename) if not os.path.exists(dir): - os.mkdir(dir) + os.mkdir(dir) zip = zipfile.ZipFile(zipFilename) - zip.extractall(dir) + self.zipExtractAll(zip, dir) def checkGMock(self): @@ -360,10 +360,22 @@ class InternalCommands: raise Exception('GMock zip not found at: ' + zipFilename) if not os.path.exists(dir): - os.mkdir(dir) + os.mkdir(dir) zip = zipfile.ZipFile(zipFilename) - zip.extractall(dir) + self.zipExtractAll(zip, dir) + + # ZipFile.extractall() is buggy in 2.6.1 + # http://bugs.python.org/issue4710 + def zipExtractAll(self, z, dir): + if not dir.endswith("/"): + dir += "/" + + for f in z.namelist(): + if f.endswith("/"): + os.makedirs(dir + f) + else: + z.extract(f, dir) def configure(self, target='', extraArgs=''):