Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
c511aee0
Commit
c511aee0
authored
Apr 11, 1997
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Open files in binary mode.
parent
f4f756cf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
Lib/urllib.py
Lib/urllib.py
+4
-4
No files found.
Lib/urllib.py
View file @
c511aee0
...
...
@@ -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
,
'w
b
'
)
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
),
'r
b
'
),
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
),
'r
b
'
),
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
,
'r
b
'
)
data
=
fp
.
read
()
del
fp
print
regsub
.
gsub
(
'
\
r
'
,
''
,
data
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment