From d23d9409f311d53e0968fd65a6cdab1777e410ab Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Thu, 30 Jan 1997 15:54:58 +0000 Subject: [PATCH] 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__... --- Lib/urllib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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]) -- 2.50.1