mirror of
https://github.com/python/cpython.git
synced 2025-11-01 02:38:53 +00:00
Massive changes from SF 589982 (tempfile.py rewrite, by Zack
Weinberg). This changes all uses of deprecated tempfile functions to the recommended ones.
This commit is contained in:
parent
830a5151c1
commit
3b0a3293c3
31 changed files with 134 additions and 149 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue