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
01fe5fa8
Commit
01fe5fa8
authored
Jul 07, 2012
by
Senthil Kumaran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix issue14826 - make urllib.request.Request quoted url consistent with URLOpener open method.
Patch contributed by Stephen Thorne.
parent
5356af8c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
2 deletions
+14
-2
Lib/test/test_urllib2.py
Lib/test/test_urllib2.py
+6
-0
Lib/urllib2.py
Lib/urllib2.py
+3
-2
Misc/NEWS
Misc/NEWS
+5
-0
No files found.
Lib/test/test_urllib2.py
View file @
01fe5fa8
...
...
@@ -1325,6 +1325,12 @@ class RequestTests(unittest.TestCase):
req
=
Request
(
"<URL:http://www.python.org>"
)
self
.
assertEqual
(
"www.python.org"
,
req
.
get_host
())
def
test_quoted_full_url
(
self
):
Request
=
urllib2
.
Request
request
=
Request
(
'http://www.python.org/foo bar'
)
self
.
assertEqual
(
request
.
get_full_url
(),
'http://www.python.org/foo%20bar'
)
def
test_url_fragment
(
self
):
req
=
Request
(
"http://www.python.org/?qs=query#fragment=true"
)
self
.
assertEqual
(
"/?qs=query"
,
req
.
get_selector
())
...
...
Lib/urllib2.py
View file @
01fe5fa8
...
...
@@ -110,7 +110,7 @@ except ImportError:
from
StringIO
import
StringIO
from
urllib
import
(
unwrap
,
unquote
,
splittype
,
splithost
,
quote
,
addinfourl
,
splitport
,
splittag
,
addinfourl
,
splitport
,
splittag
,
toBytes
,
splitattr
,
ftpwrapper
,
splituser
,
splitpasswd
,
splitvalue
)
# support for FileHandler, proxies via environment variables
...
...
@@ -196,7 +196,8 @@ class Request:
def __init__(self, url, data=None, headers={},
origin_req_host=None, unverifiable=False):
# unwrap('<URL:type://host/path>') --> 'type://host/path'
self.__original = unwrap(url)
self.__original = unwrap(toBytes(url))
self.__original = quote(self.__original, safe="
%/
:
=&
?
~
#+!$,;'@()*[]|")
self
.
__original
,
self
.
__fragment
=
splittag
(
self
.
__original
)
self
.
type
=
None
# self.__r_type is what's left after doing the splittype
...
...
Misc/NEWS
View file @
01fe5fa8
...
...
@@ -84,6 +84,11 @@ Core and Builtins
Library
-------
- Issue #14826: Quote urls in urllib2.Request identically to how they
are quoted by urllib.URLopener. Allows urls to spaces in them to work
transparently with urllib.request.urlopen(...). Patch contributed by Stephen
Thorne.
- Issue #15247: FileIO now raises an error when given a file descriptor
pointing to a directory.
...
...
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