Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests fail under python3.9: urllib.parse.unquote accepts bytes #541

Closed
keszybz opened this issue Feb 3, 2020 · 0 comments · Fixed by #578
Closed

tests fail under python3.9: urllib.parse.unquote accepts bytes #541

keszybz opened this issue Feb 3, 2020 · 0 comments · Fixed by #578

Comments

@keszybz
Copy link

keszybz commented Feb 3, 2020

________________________ UnquotingTests.test_unquoting _________________________

self = <test_future.test_urllib_toplevel.UnquotingTests testMethod=test_unquoting>

    def test_unquoting(self):
        # Make sure unquoting of all ASCII values works
        escape_list = []
        for num in range(128):
            given = hexescape(chr(num))
            expect = chr(num)
            result = urllib_parse.unquote(given)
            self.assertEqual(expect, result,
                             "using unquote(): %r != %r" % (expect, result))
            result = urllib_parse.unquote_plus(given)
            self.assertEqual(expect, result,
                             "using unquote_plus(): %r != %r" %
                             (expect, result))
            escape_list.append(given)
        escape_string = ''.join(escape_list)
        del escape_list
        result = urllib_parse.unquote(escape_string)
        self.assertEqual(result.count('%'), 1,
                         "using unquote(): not all characters escaped: "
                         "%s" % result)
        self.assertRaises((TypeError, AttributeError), urllib_parse.unquote, None)
        self.assertRaises((TypeError, AttributeError), urllib_parse.unquote, ())
        with support.check_warnings(('', BytesWarning), quiet=True):
>           self.assertRaises((TypeError, AttributeError), urllib_parse.unquote, bytes(b''))
E           AssertionError: (<class 'TypeError'>, <class 'AttributeError'>) not raised by unquote

tests/test_future/test_urllib_toplevel.py:785: AssertionError

python3.8:

>>> import urllib.parse
>>> urllib.parse.unquote(b'')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python3.7/urllib/parse.py", line 609, in unquote
    if '%' not in string:
TypeError: a bytes-like object is required, not 'str'

python3.9:

>>> import urllib.parse
>>> urllib.parse.unquote(b'')
''
hroncok added a commit to hroncok/python-future that referenced this issue Feb 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant