summaryrefslogtreecommitdiffstats
path: root/meta-python
diff options
context:
space:
mode:
authorGyorgy Sarvari <skandigraun@gmail.com>2025-10-19 15:10:46 +0200
committerGyorgy Sarvari <skandigraun@gmail.com>2025-10-20 12:00:28 +0200
commitfd9bd9dba21fd16cc8073288532d4c183c64ffb4 (patch)
tree1eb87fa2d9b25561d10b964f6fb79e16bdf933d8 /meta-python
parent6c8ae54fc345fb6249f1cc92ed769d451ddc12b5 (diff)
downloadmeta-openembedded-fd9bd9dba21fd16cc8073288532d4c183c64ffb4.tar.gz
python3-yarl: fix ptests (and make it compatible with current python)
oe-core currently ships with Python 3.10.18. Python 3.10.17 has introduced a change in urlparse library, regarding how brackets are handled by urllib.parse.urlsplit() and urlparse() functions (which makes it more conformant to the specification). This has caused a regression in yarl: some tests have failed, and it also revealed a bug in how yarl treates brackets. This backported patch corrects this behavior, making it compatible once again with the current Python version - and it also allows the the ptests to pass once again. Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
Diffstat (limited to 'meta-python')
-rw-r--r--meta-python/recipes-devtools/python/python3-yarl/0001-Correct-square-bracket-handling-in-URL-netloc-882.patch138
-rw-r--r--meta-python/recipes-devtools/python/python3-yarl_1.7.2.bb3
2 files changed, 140 insertions, 1 deletions
diff --git a/meta-python/recipes-devtools/python/python3-yarl/0001-Correct-square-bracket-handling-in-URL-netloc-882.patch b/meta-python/recipes-devtools/python/python3-yarl/0001-Correct-square-bracket-handling-in-URL-netloc-882.patch
new file mode 100644
index 0000000000..293ce88a13
--- /dev/null
+++ b/meta-python/recipes-devtools/python/python3-yarl/0001-Correct-square-bracket-handling-in-URL-netloc-882.patch
@@ -0,0 +1,138 @@
1From 0a94c6e4948e00fff072c0cf367afbf4ac36f906 Mon Sep 17 00:00:00 2001
2From: Martijn Pieters <github.com@zopatista.com>
3Date: Wed, 14 Jun 2023 11:17:16 +0100
4Subject: [PATCH] Correct square bracket handling in URL netloc (#882)
5
6- The human representation of usernames and passwords should percent-
7 encode square brackets.
8- Clean up the test suite to remove tests that use invalid hostnames
9 (square brackets in a host name must only be used for IPv6 addresses).
10- Rename the remaining test using IPvFuture address syntax to make this
11 explicit.
12- Drop a test for IPv6 addresses with a zone id; zone id support is
13 controversial and expilictly excluded from the WHATWG URL standard.
14 Zone ids *without percent characters in their name* continue to work
15 as long as urllib.parse.urlsplit() accepts them but this is not
16 something that yarl.URL() needs to support explicitly.
17
18Upstream-Status: Backport [https://github.com/aio-libs/yarl/commit/0a94c6e4948e00fff072c0cf367afbf4ac36f906]
19Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
20
21---
22 CHANGES/876.bugfix.rst | 1 +
23 tests/test_url.py | 10 ++--------
24 tests/test_url_parsing.py | 28 ++--------------------------
25 yarl/_url.py | 4 ++--
26 4 files changed, 7 insertions(+), 36 deletions(-)
27 create mode 100644 CHANGES/876.bugfix.rst
28
29diff --git a/CHANGES/876.bugfix.rst b/CHANGES/876.bugfix.rst
30new file mode 100644
31index 0000000..ef62c7e
32--- /dev/null
33+++ b/CHANGES/876.bugfix.rst
34@@ -0,0 +1 @@
35+Fixed the human representation of URLs with square brackets in usernames and passwords.
36diff --git a/tests/test_url.py b/tests/test_url.py
37index 1981b20..295c063 100644
38--- a/tests/test_url.py
39+++ b/tests/test_url.py
40@@ -236,12 +236,6 @@ def test_compressed_ipv6():
41 assert url.host == url.raw_host
42
43
44-def test_ipv6_zone():
45- url = URL("http://[fe80::822a:a8ff:fe49:470c%тест%42]:123")
46- assert url.raw_host == "fe80::822a:a8ff:fe49:470c%тест%42"
47- assert url.host == url.raw_host
48-
49-
50 def test_ipv4_zone():
51 # I'm unsure if it is correct.
52 url = URL("http://1.2.3.4%тест%42:123")
53@@ -1660,8 +1654,8 @@ def test_human_repr_delimiters():
54 s = url.human_repr()
55 assert URL(s) == url
56 assert (
57- s == "http:// !\"%23$%25&'()*+,-.%2F%3A;<=>%3F%40[\\]^_`{|}~"
58- ": !\"%23$%25&'()*+,-.%2F%3A;<=>%3F%40[\\]^_`{|}~"
59+ s == "http:// !\"%23$%25&'()*+,-.%2F%3A;<=>%3F%40%5B\\%5D^_`{|}~"
60+ ": !\"%23$%25&'()*+,-.%2F%3A;<=>%3F%40%5B\\%5D^_`{|}~"
61 "@хост.домен:8080"
62 "/ !\"%23$%25&'()*+,-./:;<=>%3F@[\\]^_`{|}~"
63 "? !\"%23$%25%26'()*%2B,-./:%3B<%3D>?@[\\]^_`{|}~"
64diff --git a/tests/test_url_parsing.py b/tests/test_url_parsing.py
65index 0f0dd7e..60f128c 100644
66--- a/tests/test_url_parsing.py
67+++ b/tests/test_url_parsing.py
68@@ -178,14 +178,6 @@ class TestHost:
69 assert u.query_string == ""
70 assert u.fragment == ""
71
72- def test_masked_ipv4(self):
73- u = URL("//[127.0.0.1]/")
74- assert u.scheme == ""
75- assert u.host == "127.0.0.1"
76- assert u.path == "/"
77- assert u.query_string == ""
78- assert u.fragment == ""
79-
80 def test_ipv6(self):
81 u = URL("//[::1]/")
82 assert u.scheme == ""
83@@ -194,15 +186,7 @@ class TestHost:
84 assert u.query_string == ""
85 assert u.fragment == ""
86
87- def test_strange_ip(self):
88- u = URL("//[-1]/")
89- assert u.scheme == ""
90- assert u.host == "-1"
91- assert u.path == "/"
92- assert u.query_string == ""
93- assert u.fragment == ""
94-
95- def test_strange_ip_2(self):
96+ def test_ipvfuture_address(self):
97 u = URL("//[v1.-1]/")
98 assert u.scheme == ""
99 assert u.host == "v1.-1"
100@@ -210,14 +194,6 @@ class TestHost:
101 assert u.query_string == ""
102 assert u.fragment == ""
103
104- def test_strange_ip_3(self):
105- u = URL("//v1.[::1]/")
106- assert u.scheme == ""
107- assert u.host == "::1"
108- assert u.path == "/"
109- assert u.query_string == ""
110- assert u.fragment == ""
111-
112
113 class TestPort:
114 def test_canonical(self):
115@@ -320,7 +296,7 @@ class TestUserInfo:
116 assert u.fragment == ""
117
118 def test_weird_user3(self):
119- u = URL("//[some]@host")
120+ u = URL("//%5Bsome%5D@host")
121 assert u.scheme == ""
122 assert u.user == "[some]"
123 assert u.password is None
124diff --git a/yarl/_url.py b/yarl/_url.py
125index 74190d9..c8f2acb 100644
126--- a/yarl/_url.py
127+++ b/yarl/_url.py
128@@ -1118,8 +1118,8 @@ class URL:
129
130 def human_repr(self):
131 """Return decoded human readable string for URL representation."""
132- user = _human_quote(self.user, "#/:?@")
133- password = _human_quote(self.password, "#/:?@")
134+ user = _human_quote(self.user, "#/:?@[]")
135+ password = _human_quote(self.password, "#/:?@[]")
136 host = self.host
137 if host:
138 host = self._encode_host(self.host, human=True)
diff --git a/meta-python/recipes-devtools/python/python3-yarl_1.7.2.bb b/meta-python/recipes-devtools/python/python3-yarl_1.7.2.bb
index 0867d1cb53..902cace048 100644
--- a/meta-python/recipes-devtools/python/python3-yarl_1.7.2.bb
+++ b/meta-python/recipes-devtools/python/python3-yarl_1.7.2.bb
@@ -5,7 +5,8 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=e581798a7b985311f29fa3e163ea27ae"
5 5
6SRC_URI[sha256sum] = "45399b46d60c253327a460e99856752009fcee5f5d3c80b2f7c0cae1c38d56dd" 6SRC_URI[sha256sum] = "45399b46d60c253327a460e99856752009fcee5f5d3c80b2f7c0cae1c38d56dd"
7 7
8SRC_URI += "file://run-ptest" 8SRC_URI += "file://run-ptest \
9 file://0001-Correct-square-bracket-handling-in-URL-netloc-882.patch"
9 10
10PYPI_PACKAGE = "yarl" 11PYPI_PACKAGE = "yarl"
11 12