aio-libs / yarl

Yet another URL library

Home Page:https://yarl.aio-libs.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

test_no_scheme2 fails with Python 3.11

s3v- opened this issue · comments

commented

Describe the bug

test_no_scheme2 fails with Python 3.11. See:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1026634
(or your Actions log).

> =================================== FAILURES ===================================
> ________________________ TestScheme.test_not_a_scheme2 _________________________
> 
> self = <test_url_parsing.TestScheme object at 0x7f6efadeb150>
> 
>     def test_not_a_scheme2(self):
>         u = URL("37signals:book")
> >       assert u.scheme == "37signals"
> E       AssertionError: assert '' == '37signals'
> E         - 37signals
> 
> tests/test_url_parsing.py:77: AssertionError

Python 3.10 or lower:

Python 3.10.9 (main, Dec  7 2022, 13:47:07) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from urllib.parse import urlsplit
>>> urlsplit('37signals:book')
SplitResult(scheme='37signals', netloc='', path='book', query='', fragment='')
>>> 

Python 3.11:

Python 3.11.1 (main, Dec  7 2022, 08:49:13) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from urllib.parse import urlsplit
>>> urlsplit('37signals:book')
SplitResult(scheme='', netloc='', path='37signals:book', query='', fragment='')
>>> 

Kind Regards

To Reproduce

Just run the test with Python 3.11

Expected behavior

Test succeeds

Logs/tracebacks

n\a

Python Version

Python 3.11.1

multidict Version

n\a

yarl Version

n\a

OS

Debian

Additional context

No response

Code of Conduct

  • I agree to follow the aio-libs Code of Conduct

Looks like there was a change in how the stdlib behaves. The question is why. We need to see the upstream patch and the motivation behind it.

commented

This is the relevant commit:
python/cpython@72d356e

Thanks for your work.

Aha! So it's not a bug in that patch but in our test. I suppose that it's easy to fix it by moving 37 away from the beginning of the scheme? I wonder what is the purpose of the test...

commented

yarl parsing is coherent with new behavior of urlsplit for Python 3.11.

Python 3.11.1 (main, Dec 31 2022, 10:23:59) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from yarl import URL
>>> url = URL('37signals:book')
>>> url.scheme
''
>>> url.path
'37signals:book'
>>> 

I think failing test just need to be adapted to python 3.11 like test_no_scheme1 did for different Python versions.

Kind Regards

This will actually happen with all Python interpreters patched against CVE-2023-24329 (see python/cpython#102153).