summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1997-04-11 19:01:48 (GMT)
committerGuido van Rossum <guido@python.org>1997-04-11 19:01:48 (GMT)
commitc511aee0e37d82639dcd4f9b3d0446b8a05d8077 (patch)
treeef69ebb580b7f3d12962e182b64df07ab5e5342e /Lib
parentf4f756cf55c7ec6534c7d952e2f8af672290aa02 (diff)
downloadcpython-c511aee0e37d82639dcd4f9b3d0446b8a05d8077.zip
cpython-c511aee0e37d82639dcd4f9b3d0446b8a05d8077.tar.gz
cpython-c511aee0e37d82639dcd4f9b3d0446b8a05d8077.tar.bz2
Open files in binary mode.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/urllib.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/Lib/urllib.py b/Lib/urllib.py
index 49c9032..e57311b 100644
--- a/Lib/urllib.py
+++ b/Lib/urllib.py
@@ -183,7 +183,7 @@ class URLopener:
result = filename, headers
if self.tempcache is not None:
self.tempcache[url] = result
- tfp = open(filename, 'w')
+ tfp = open(filename, 'wb')
bs = 1024*8
block = fp.read(bs)
while block:
@@ -284,12 +284,12 @@ class URLopener:
def open_local_file(self, url):
host, file = splithost(url)
if not host:
- return addinfourl(open(url2pathname(file), 'r'), noheaders(), 'file:'+file)
+ return addinfourl(open(url2pathname(file), 'rb'), noheaders(), 'file:'+file)
host, port = splitport(host)
if not port and socket.gethostbyname(host) in (
localhost(), thishost()):
file = unquote(file)
- return addinfourl(open(url2pathname(file), 'r'), noheaders(), 'file:'+file)
+ return addinfourl(open(url2pathname(file), 'rb'), noheaders(), 'file:'+file)
raise IOError, ('local file error', 'not on local host')
# Use FTP protocol
@@ -785,7 +785,7 @@ def test():
print '======'
for k in h.keys(): print k + ':', h[k]
print '======'
- fp = open(fn, 'r')
+ fp = open(fn, 'rb')
data = fp.read()
del fp
print regsub.gsub('\r', '', data)