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
d496c4c9
Commit
d496c4c9
authored
Jul 30, 2010
by
Senthil Kumaran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix issue9301 - handle unquote({}) kind of case.
parent
0a9c3e91
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
7 deletions
+5
-7
Lib/test/test_urllib.py
Lib/test/test_urllib.py
+3
-1
Lib/urllib/parse.py
Lib/urllib/parse.py
+2
-6
No files found.
Lib/test/test_urllib.py
View file @
d496c4c9
...
...
@@ -527,6 +527,7 @@ class QuotingTests(unittest.TestCase):
self.assertEqual(expect, result,
"using quote_plus(): %r != %r" % (expect, result))
class UnquotingTests(unittest.TestCase):
"""Tests for unquote() and unquote_plus()
...
...
@@ -555,6 +556,7 @@ class UnquotingTests(unittest.TestCase):
"using unquote(): not all characters escaped: "
"%s" % result)
self.assertRaises(TypeError, urllib.parse.unquote, None)
self.assertRaises(TypeError, urllib.parse.unquote, ())
def test_unquoting_badpercent(self):
# Test unquoting on bad percent-escapes
...
...
@@ -589,8 +591,8 @@ class UnquotingTests(unittest.TestCase):
result = urllib.parse.unquote_to_bytes(given)
self.assertEqual(expect, result, "using unquote_to_bytes(): %r != %r"
% (expect, result))
self.assertRaises(TypeError, urllib.parse.unquote_to_bytes, None)
self.assertRaises(TypeError, urllib.parse.unquote_to_bytes, ())
def test_unquoting_mixed_case(self):
# Test unquoting on mixed-case hex digits in the percent-escapes
...
...
Lib/urllib/parse.py
View file @
d496c4c9
...
...
@@ -313,9 +313,7 @@ def unquote_to_bytes(string):
"""unquote_to_bytes('abc%20def') -> b'abc def'."""
# Note: strings are encoded as UTF-8. This is only an issue if it contains
# unescaped non-ASCII characters, which URIs should not.
if
not
string
:
if
string
is
None
:
raise
TypeError
(
'None object is invalid for unquote_to_bytes()'
)
if
string
in
(
b''
,
''
):
return
b''
if
isinstance
(
string
,
str
):
string
=
string
.
encode
(
'utf-8'
)
...
...
@@ -340,9 +338,7 @@ def unquote(string, encoding='utf-8', errors='replace'):
unquote('abc%20def') -> 'abc def'.
"""
if
not
string
:
if
string
is
None
:
raise
TypeError
(
'None object is invalid for unquote() function.'
)
if
string
in
(
b''
,
''
):
return
string
res
=
string
.
split
(
'%'
)
if
len
(
res
)
==
1
:
...
...
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