summaryrefslogtreecommitdiffstats
path: root/Lib/urllib.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2002-08-09 16:38:32 (GMT)
committerGuido van Rossum <guido@python.org>2002-08-09 16:38:32 (GMT)
commit3b0a3293c369f3c3f4753e3cb9172cb4e242af76 (patch)
treee0f9d295c0a2897ddfb7a5bf3b076be70f1492b4 /Lib/urllib.py
parent830a5151c1e2ed4d0c647efb4ad54a9a6c67e4ae (diff)
downloadcpython-3b0a3293c369f3c3f4753e3cb9172cb4e242af76.zip
cpython-3b0a3293c369f3c3f4753e3cb9172cb4e242af76.tar.gz
cpython-3b0a3293c369f3c3f4753e3cb9172cb4e242af76.tar.bz2
Massive changes from SF 589982 (tempfile.py rewrite, by Zack
Weinberg). This changes all uses of deprecated tempfile functions to the recommended ones.
Diffstat (limited to 'Lib/urllib.py')
-rw-r--r--Lib/urllib.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/Lib/urllib.py b/Lib/urllib.py
index 4d686b9..d367dd8 100644
--- a/Lib/urllib.py
+++ b/Lib/urllib.py
@@ -212,19 +212,21 @@ class URLopener:
pass
fp = self.open(url, data)
headers = fp.info()
- if not filename:
+ if filename:
+ tfp = open(filename, 'wb')
+ else:
import tempfile
garbage, path = splittype(url)
garbage, path = splithost(path or "")
path, garbage = splitquery(path or "")
path, garbage = splitattr(path or "")
suffix = os.path.splitext(path)[1]
- filename = tempfile.mktemp(suffix)
+ (fd, filename) = tempfile.mkstemp(suffix)
self.__tempfiles.append(filename)
+ tfp = os.open(fd, 'wb')
result = filename, headers
if self.tempcache is not None:
self.tempcache[url] = result
- tfp = open(filename, 'wb')
bs = 1024*8
size = -1
blocknum = 1