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
b52c6f8c
Commit
b52c6f8c
authored
Aug 15, 2009
by
Senthil Kumaran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixing Issue6557. urllib.urlopen will quote the space character within urls.
parent
f492c364
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
0 deletions
+15
-0
Lib/test/test_urllib.py
Lib/test/test_urllib.py
+12
-0
Lib/urllib.py
Lib/urllib.py
+3
-0
No files found.
Lib/test/test_urllib.py
View file @
b52c6f8c
...
...
@@ -582,6 +582,17 @@ class Pathname_Tests(unittest.TestCase):
"url2pathname() failed; %s != %s" %
(expect, result))
class URLopener_Tests(unittest.TestCase):
"""Testcase to test the open method of URLopener class."""
def test_quoted_open(self):
class DummyURLopener(urllib.URLopener):
def open_spam(self, url):
return url
self.assertEqual(DummyURLopener().open(
'
spam
:
//
example
/
/
'),'
//
example
/%
20
/
')
# Just commented them out.
# Can'
t
really
tell
why
keep
failing
in
windows
and
sparc
.
# Everywhere else they work ok, but on those machines, someteimes
...
...
@@ -676,6 +687,7 @@ def test_main():
UnquotingTests
,
urlencode_Tests
,
Pathname_Tests
,
URLopener_Tests
,
#FTPWrapperTests,
)
...
...
Lib/urllib.py
View file @
b52c6f8c
...
...
@@ -176,6 +176,9 @@ class URLopener:
def
open
(
self
,
fullurl
,
data
=
None
):
"""Use URLopener().open(file) instead of open(file, 'r')."""
fullurl
=
unwrap
(
toBytes
(
fullurl
))
# percent encode url. fixing lame server errors like space within url
# parts
fullurl
=
quote
(
fullurl
,
safe
=
"%/:=&?~#+!$,;'@()*[]"
)
if
self
.
tempcache
and
fullurl
in
self
.
tempcache
:
filename
,
headers
=
self
.
tempcache
[
fullurl
]
fp
=
open
(
filename
,
'rb'
)
...
...
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