From: Guido van Rossum Date: Thu, 30 Jan 1997 15:54:58 +0000 (+0000) Subject: Move the 'import os' in URLopener.cleanup() to inside the block X-Git-Tag: v1.5a1~404 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d23d9409f311d53e0968fd65a6cdab1777e410ab;p=thirdparty%2FPython%2Fcpython.git Move the 'import os' in URLopener.cleanup() to inside the block guarded by 'if self.tempcache', to reduce the likelihood of this causing an exception when invoked during __del__... --- diff --git a/Lib/urllib.py b/Lib/urllib.py index e44f6b1435d3..b410bd89a760 100644 --- a/Lib/urllib.py +++ b/Lib/urllib.py @@ -101,8 +101,8 @@ class URLopener: self.cleanup() def cleanup(self): - import os if self.tempcache: + import os for url in self.tempcache.keys(): try: os.unlink(self.tempcache[url][0])