Skip to content

Commit b25db34

Browse files
Merge branch 'master' into python3.13
2 parents 1357986 + 2d35f10 commit b25db34

File tree

8 files changed

+42
-16
lines changed

8 files changed

+42
-16
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ jobs:
1313
test:
1414
runs-on: ${{ matrix.os }}
1515
strategy:
16+
fail-fast: false
1617
matrix:
1718
python-version:
1819
- "3.8"

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ To build uvloop, you'll need Python 3.8 or greater:
109109

110110
.. code::
111111
112-
$ python3.7 -m venv uvloop-dev
112+
$ python3 -m venv uvloop-dev
113113
$ source uvloop-dev/bin/activate
114114
115115
3. Install development dependencies:

setup.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,11 @@ def build_libuv(self):
176176
cmd,
177177
cwd=LIBUV_BUILD_DIR, env=env, check=True)
178178

179-
j_flag = '-j{}'.format(os.cpu_count() or 1)
179+
try:
180+
njobs = len(os.sched_getaffinity(0))
181+
except AttributeError:
182+
njobs = os.cpu_count()
183+
j_flag = '-j{}'.format(njobs or 1)
180184
c_flag = "CFLAGS={}".format(env['CFLAGS'])
181185
subprocess.run(
182186
['make', j_flag, c_flag],

tests/test_dns.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ def _test_getaddrinfo(self, *args, _patch=False, **kwargs):
3131
a1 = patched_getaddrinfo(*args, **kwargs)
3232
else:
3333
a1 = socket.getaddrinfo(*args, **kwargs)
34-
except socket.gaierror as ex:
34+
except (socket.gaierror, UnicodeError) as ex:
3535
err = ex
3636

3737
try:
3838
a2 = self.loop.run_until_complete(
3939
self.loop.getaddrinfo(*args, **kwargs))
40-
except socket.gaierror as ex:
40+
except (socket.gaierror, UnicodeError) as ex:
4141
if err is not None:
4242
self.assertEqual(ex.args, err.args)
4343
else:
@@ -187,6 +187,18 @@ def test_getaddrinfo_20(self):
187187
self._test_getaddrinfo('127.0.0.1', 80, type=socket.SOCK_STREAM,
188188
flags=socket.AI_CANONNAME, _patch=patch)
189189

190+
# https://github.com/libuv/libuv/security/advisories/GHSA-f74f-cvh7-c6q6
191+
# See also: https://github.com/MagicStack/uvloop/pull/600
192+
def test_getaddrinfo_21(self):
193+
payload = f'0x{"0" * 246}7f000001.example.com'.encode('ascii')
194+
self._test_getaddrinfo(payload, 80)
195+
self._test_getaddrinfo(payload, 80, type=socket.SOCK_STREAM)
196+
197+
def test_getaddrinfo_22(self):
198+
payload = f'0x{"0" * 246}7f000001.example.com'
199+
self._test_getaddrinfo(payload, 80)
200+
self._test_getaddrinfo(payload, 80, type=socket.SOCK_STREAM)
201+
190202
######
191203

192204
def test_getnameinfo_1(self):

tests/test_tcp.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,9 @@ def test_create_server_4(self):
248248
addr = sock.getsockname()
249249

250250
with self.assertRaisesRegex(OSError,
251-
r"error while attempting.*\('127.*: "
252-
r"address( already)? in use"):
251+
r"error while attempting.*\('127.*:"
252+
r"( \[errno \d+\])? address"
253+
r"( already)? in use"):
253254

254255
self.loop.run_until_complete(
255256
self.loop.create_server(object, *addr))

uvloop/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
# supported platforms, publish the packages on PyPI, merge the PR
1111
# to the target branch, create a Git tag pointing to the commit.
1212

13-
__version__ = '0.19.0'
13+
__version__ = '0.20.0'

uvloop/dns.pyx

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,11 @@ cdef class AddrInfoRequest(UVRequest):
348348

349349
if host is None:
350350
chost = NULL
351+
elif host == b'' and sys.platform == 'darwin':
352+
# It seems `getaddrinfo("", ...)` on macOS is equivalent to
353+
# `getaddrinfo("localhost", ...)`. This is inconsistent with
354+
# libuv 1.48 which treats empty nodename as EINVAL.
355+
chost = <char*>'localhost'
351356
else:
352357
chost = <char*>host
353358

@@ -356,13 +361,6 @@ cdef class AddrInfoRequest(UVRequest):
356361
else:
357362
cport = <char*>port
358363

359-
if cport is NULL and chost is NULL:
360-
self.on_done()
361-
msg = system.gai_strerror(socket_EAI_NONAME).decode('utf-8')
362-
ex = socket_gaierror(socket_EAI_NONAME, msg)
363-
callback(ex)
364-
return
365-
366364
memset(&self.hints, 0, sizeof(system.addrinfo))
367365
self.hints.ai_flags = flags
368366
self.hints.ai_family = family
@@ -382,7 +380,17 @@ cdef class AddrInfoRequest(UVRequest):
382380

383381
if err < 0:
384382
self.on_done()
385-
callback(convert_error(err))
383+
try:
384+
if err == uv.UV_EINVAL:
385+
# Convert UV_EINVAL to EAI_NONAME to match libc behavior
386+
msg = system.gai_strerror(socket_EAI_NONAME).decode('utf-8')
387+
ex = socket_gaierror(socket_EAI_NONAME, msg)
388+
else:
389+
ex = convert_error(err)
390+
except Exception as ex:
391+
callback(ex)
392+
else:
393+
callback(ex)
386394

387395

388396
cdef class NameInfoRequest(UVRequest):

vendor/libuv

Submodule libuv updated 240 files

0 commit comments

Comments
 (0)