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
ea24dda0
Commit
ea24dda0
authored
May 19, 2012
by
Senthil Kumaran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue9374 - Generic parsing of query and fragment portion of urls for any scheme
parent
280e9f7c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
9 deletions
+9
-9
Lib/test/test_urlparse.py
Lib/test/test_urlparse.py
+4
-0
Lib/urlparse.py
Lib/urlparse.py
+2
-9
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/test/test_urlparse.py
View file @
ea24dda0
...
...
@@ -493,6 +493,10 @@ class UrlParseTestCase(unittest.TestCase):
(
's3'
,
'foo.com'
,
'/stuff'
,
''
,
''
,
''
))
self
.
assertEqual
(
urlparse
.
urlparse
(
"x-newscheme://foo.com/stuff"
),
(
'x-newscheme'
,
'foo.com'
,
'/stuff'
,
''
,
''
,
''
))
self
.
assertEqual
(
urlparse
.
urlparse
(
"x-newscheme://foo.com/stuff?query#fragment"
),
(
'x-newscheme'
,
'foo.com'
,
'/stuff'
,
''
,
'query'
,
'fragment'
))
self
.
assertEqual
(
urlparse
.
urlparse
(
"x-newscheme://foo.com/stuff?query"
),
(
'x-newscheme'
,
'foo.com'
,
'/stuff'
,
''
,
'query'
,
''
))
def
test_withoutscheme
(
self
):
# Test urlparse without scheme
...
...
Lib/urlparse.py
View file @
ea24dda0
...
...
@@ -40,16 +40,9 @@ uses_netloc = ['ftp', 'http', 'gopher', 'nntp', 'telnet',
'imap'
,
'wais'
,
'file'
,
'mms'
,
'https'
,
'shttp'
,
'snews'
,
'prospero'
,
'rtsp'
,
'rtspu'
,
'rsync'
,
''
,
'svn'
,
'svn+ssh'
,
'sftp'
,
'nfs'
,
'git'
,
'git+ssh'
]
non_hierarchical
=
[
'gopher'
,
'hdl'
,
'mailto'
,
'news'
,
'telnet'
,
'wais'
,
'imap'
,
'snews'
,
'sip'
,
'sips'
]
uses_params
=
[
'ftp'
,
'hdl'
,
'prospero'
,
'http'
,
'imap'
,
'https'
,
'shttp'
,
'rtsp'
,
'rtspu'
,
'sip'
,
'sips'
,
'mms'
,
''
,
'sftp'
]
uses_query
=
[
'http'
,
'wais'
,
'imap'
,
'https'
,
'shttp'
,
'mms'
,
'gopher'
,
'rtsp'
,
'rtspu'
,
'sip'
,
'sips'
,
''
]
uses_fragment
=
[
'ftp'
,
'hdl'
,
'http'
,
'gopher'
,
'news'
,
'nntp'
,
'wais'
,
'https'
,
'shttp'
,
'snews'
,
'file'
,
'prospero'
,
''
]
# Characters valid in scheme names
scheme_chars
=
(
'abcdefghijklmnopqrstuvwxyz'
...
...
@@ -204,9 +197,9 @@ def urlsplit(url, scheme='', allow_fragments=True):
if
((
'['
in
netloc
and
']'
not
in
netloc
)
or
(
']'
in
netloc
and
'['
not
in
netloc
)):
raise
ValueError
(
"Invalid IPv6 URL"
)
if
allow_fragments
and
scheme
in
uses_fragment
and
'#'
in
url
:
if
allow_fragments
and
'#'
in
url
:
url
,
fragment
=
url
.
split
(
'#'
,
1
)
if
scheme
in
uses_query
and
'?'
in
url
:
if
'?'
in
url
:
url
,
query
=
url
.
split
(
'?'
,
1
)
v
=
SplitResult
(
scheme
,
netloc
,
url
,
query
,
fragment
)
_parse_cache
[
key
]
=
v
...
...
Misc/NEWS
View file @
ea24dda0
...
...
@@ -60,6 +60,9 @@ Core and Builtins
Library
-------
-
Issue
#
9374
:
Generic
parsing
of
query
and
fragment
portions
of
url
for
any
scheme
.
Supported
both
by
RFC3986
and
RFC2396
.
-
Issue
#
14798
:
Fix
the
functions
in
pyclbr
to
raise
an
ImportError
when
the
first
part
of
a
dotted
name
is
not
a
package
.
Patch
by
Xavier
de
Gaye
.
...
...
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