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
fce59bf7
Commit
fce59bf7
authored
Aug 25, 2007
by
Neal Norwitz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Get the urllib tests to pass without the email package
parent
0337ef62
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
4 deletions
+24
-4
Lib/urllib.py
Lib/urllib.py
+12
-2
Lib/urllib2.py
Lib/urllib2.py
+12
-2
No files found.
Lib/urllib.py
View file @
fce59bf7
...
...
@@ -403,7 +403,7 @@ class URLopener:
def
open_local_file
(
self
,
url
):
"""Use local file."""
import
mimetypes
,
mimetools
,
email
.
utils
import
mimetypes
,
mimetools
#
, email.utils
from
io
import
StringIO
host
,
file
=
splithost
(
url
)
localname
=
url2pathname
(
file
)
...
...
@@ -412,7 +412,17 @@ class URLopener:
except
OSError
as
e
:
raise
IOError
(
e
.
errno
,
e
.
strerror
,
e
.
filename
)
size
=
stats
.
st_size
modified
=
email
.
utils
.
formatdate
(
stats
.
st_mtime
,
usegmt
=
True
)
# XXX(nnorwitz): inline formatdate until it is restored.
#modified = email.utils.formatdate(stats.st_mtime, usegmt=True)
now
,
zone
=
time
.
gmtime
(
stats
.
st_mtime
),
'GMT'
modified
=
'%s, %02d %s %04d %02d:%02d:%02d %s'
%
(
[
'Mon'
,
'Tue'
,
'Wed'
,
'Thu'
,
'Fri'
,
'Sat'
,
'Sun'
][
now
[
6
]],
now
[
2
],
[
'Jan'
,
'Feb'
,
'Mar'
,
'Apr'
,
'May'
,
'Jun'
,
'Jul'
,
'Aug'
,
'Sep'
,
'Oct'
,
'Nov'
,
'Dec'
][
now
[
1
]
-
1
],
now
[
0
],
now
[
3
],
now
[
4
],
now
[
5
],
zone
)
mtype
=
mimetypes
.
guess_type
(
url
)[
0
]
headers
=
mimetools
.
Message
(
StringIO
(
'Content-Type: %s
\
n
Content-Length: %d
\
n
Last-modified: %s
\
n
'
%
...
...
Lib/urllib2.py
View file @
fce59bf7
...
...
@@ -1201,7 +1201,7 @@ class FileHandler(BaseHandler):
# not entirely sure what the rules are here
def
open_local_file
(
self
,
req
):
import
email.utils
#
import email.utils
import
mimetypes
host
=
req
.
get_host
()
file
=
req
.
get_selector
()
...
...
@@ -1209,7 +1209,17 @@ class FileHandler(BaseHandler):
try
:
stats
=
os
.
stat
(
localfile
)
size
=
stats
.
st_size
modified
=
email
.
utils
.
formatdate
(
stats
.
st_mtime
,
usegmt
=
True
)
#modified = email.utils.formatdate(stats.st_mtime, usegmt=True)
# XXX(nnorwitz): inline formatdate until it is restored.
now
,
zone
=
time
.
gmtime
(
stats
.
st_mtime
),
'GMT'
modified
=
'%s, %02d %s %04d %02d:%02d:%02d %s'
%
(
[
'Mon'
,
'Tue'
,
'Wed'
,
'Thu'
,
'Fri'
,
'Sat'
,
'Sun'
][
now
[
6
]],
now
[
2
],
[
'Jan'
,
'Feb'
,
'Mar'
,
'Apr'
,
'May'
,
'Jun'
,
'Jul'
,
'Aug'
,
'Sep'
,
'Oct'
,
'Nov'
,
'Dec'
][
now
[
1
]
-
1
],
now
[
0
],
now
[
3
],
now
[
4
],
now
[
5
],
zone
)
mtype
=
mimetypes
.
guess_type
(
file
)[
0
]
headers
=
mimetools
.
Message
(
StringIO
(
'Content-type: %s
\
n
Content-length: %d
\
n
Last-modified: %s
\
n
'
%
...
...
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