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: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d23d9409f311d53e0968fd65a6cdab1777e410ab;p=python 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 e44f6b1435..b410bd89a7 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])