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
18e4dd74
Commit
18e4dd74
authored
May 08, 2010
by
Senthil Kumaran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixing the errors trigerred in test_urllib2net. Related to issue8656.
parent
6057ba1f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
5 deletions
+8
-5
Lib/urllib2.py
Lib/urllib2.py
+8
-5
No files found.
Lib/urllib2.py
View file @
18e4dd74
...
...
@@ -1276,13 +1276,13 @@ class FileHandler(BaseHandler):
import
email.utils
import
mimetypes
host
=
req
.
get_host
()
file
=
req
.
get_selector
()
localfile
=
url2pathname
(
file
)
file
name
=
req
.
get_selector
()
localfile
=
url2pathname
(
file
name
)
try
:
stats
=
os
.
stat
(
localfile
)
size
=
stats
.
st_size
modified
=
email
.
utils
.
formatdate
(
stats
.
st_mtime
,
usegmt
=
True
)
mtype
=
mimetypes
.
guess_type
(
file
)[
0
]
mtype
=
mimetypes
.
guess_type
(
file
name
)[
0
]
headers
=
mimetools
.
Message
(
StringIO
(
'Content-type: %s
\
n
Content-length: %d
\
n
Last-modified: %s
\
n
'
%
(
mtype
or
'text/plain'
,
size
,
modified
)))
...
...
@@ -1290,8 +1290,11 @@ class FileHandler(BaseHandler):
host
,
port
=
splitport
(
host
)
if
not
host
or
\
(
not
port
and
socket
.
gethostbyname
(
host
)
in
self
.
get_names
()):
return
addinfourl
(
open
(
localfile
,
'rb'
),
headers
,
'file://'
+
host
+
file
)
if
host
:
origurl
=
'file://'
+
host
+
filename
else
:
origurl
=
'file://'
+
filename
return
addinfourl
(
open
(
localfile
,
'rb'
),
headers
,
origurl
)
except
OSError
,
msg
:
# urllib2 users shouldn't expect OSErrors coming from urlopen()
raise
URLError
(
msg
)
...
...
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