Update to Python 3.14.0a5

This commit is contained in:
Karolina Surma 2025-02-12 09:14:16 +01:00
commit a6be165890
7 changed files with 123 additions and 1004 deletions

View file

@ -30,7 +30,7 @@ Co-authored-by: Lumír Balhar <frenzy.madness@gmail.com>
3 files changed, 72 insertions(+), 4 deletions(-)
diff --git a/Lib/site.py b/Lib/site.py
index 92bd1ccdad..951784f3b4 100644
index 9da8b6724e..b53dd21d51 100644
--- a/Lib/site.py
+++ b/Lib/site.py
@@ -420,8 +420,15 @@ def getsitepackages(prefixes=None):
@ -51,7 +51,7 @@ index 92bd1ccdad..951784f3b4 100644
if os.path.isdir(sitedir):
addsitedir(sitedir, known_paths)
diff --git a/Lib/sysconfig/__init__.py b/Lib/sysconfig/__init__.py
index 7a4a8f65a5..c8fca72c01 100644
index 69f72452c4..6d5d096644 100644
--- a/Lib/sysconfig/__init__.py
+++ b/Lib/sysconfig/__init__.py
@@ -106,6 +106,12 @@
@ -67,7 +67,7 @@ index 7a4a8f65a5..c8fca72c01 100644
def _get_implementation():
return 'Python'
@@ -167,6 +173,19 @@ def joinuser(*args):
@@ -169,6 +175,19 @@ def joinuser(*args):
},
}
@ -87,7 +87,7 @@ index 7a4a8f65a5..c8fca72c01 100644
_SCHEME_KEYS = ('stdlib', 'platstdlib', 'purelib', 'platlib', 'include',
'scripts', 'data')
@@ -259,11 +278,40 @@ def _extend_dict(target_dict, other_dict):
@@ -268,11 +287,40 @@ def _extend_dict(target_dict, other_dict):
target_dict[key] = value
@ -130,10 +130,10 @@ index 7a4a8f65a5..c8fca72c01 100644
# On Windows we want to substitute 'lib' for schemes rather
# than the native value (without modifying vars, in case it
diff --git a/Lib/test/test_sysconfig.py b/Lib/test/test_sysconfig.py
index ce504dc21a..054e514130 100644
index 3738914cf1..98da62ff05 100644
--- a/Lib/test/test_sysconfig.py
+++ b/Lib/test/test_sysconfig.py
@@ -138,8 +138,19 @@ def test_get_path(self):
@@ -131,8 +131,19 @@ def test_get_path(self):
for scheme in _INSTALL_SCHEMES:
for name in _INSTALL_SCHEMES[scheme]:
expected = _INSTALL_SCHEMES[scheme][name].format(**config_vars)
@ -154,7 +154,7 @@ index ce504dc21a..054e514130 100644
os.path.normpath(expected),
)
@@ -394,7 +405,7 @@ def test_get_config_h_filename(self):
@@ -387,7 +398,7 @@ def test_get_config_h_filename(self):
self.assertTrue(os.path.isfile(config_h), config_h)
def test_get_scheme_names(self):
@ -163,7 +163,7 @@ index ce504dc21a..054e514130 100644
if HAS_USER_BASE:
wanted.extend(['nt_user', 'osx_framework_user', 'posix_user'])
self.assertEqual(get_scheme_names(), tuple(sorted(wanted)))
@@ -406,6 +417,8 @@ def test_symlink(self): # Issue 7880
@@ -399,6 +410,8 @@ def test_symlink(self): # Issue 7880
cmd = "-c", "import sysconfig; print(sysconfig.get_platform())"
self.assertEqual(py.call_real(*cmd), py.call_link(*cmd))

View file

@ -1,84 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
Date: Sat, 18 Jan 2025 01:49:16 +0100
Subject: [PATCH] 00448: gh-128916: Do not set `SO_REUSEPORT` on non-`AF_INET*`
sockets (GH-128933)
* gh-128916: Do not set `SO_REUSEPORT` on non-`AF_INET*` sockets
Do not attempt to set ``SO_REUSEPORT`` on sockets of address familifies other
than ``AF_INET`` and ``AF_INET6``, as it is meaningless with these address
families, and the call with fail with Linux kernel 6.12.9 and newer.
* Apply suggestions from code review
Co-authored-by: Vinay Sajip <vinay_sajip@yahoo.co.uk>
---------
Co-authored-by: Vinay Sajip <vinay_sajip@yahoo.co.uk>
---
Lib/asyncio/base_events.py | 4 +++-
Lib/socket.py | 4 +++-
Lib/socketserver.py | 7 ++++++-
.../Library/2025-01-17-11-46-16.gh-issue-128916.GEePbO.rst | 3 +++
4 files changed, 15 insertions(+), 3 deletions(-)
create mode 100644 Misc/NEWS.d/next/Library/2025-01-17-11-46-16.gh-issue-128916.GEePbO.rst
diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py
index 6e6e5aaac1..85018797db 100644
--- a/Lib/asyncio/base_events.py
+++ b/Lib/asyncio/base_events.py
@@ -1593,7 +1593,9 @@ async def create_server(
if reuse_address:
sock.setsockopt(
socket.SOL_SOCKET, socket.SO_REUSEADDR, True)
- if reuse_port:
+ # Since Linux 6.12.9, SO_REUSEPORT is not allowed
+ # on other address families than AF_INET/AF_INET6.
+ if reuse_port and af in (socket.AF_INET, socket.AF_INET6):
_set_reuseport(sock)
if keep_alive:
sock.setsockopt(
diff --git a/Lib/socket.py b/Lib/socket.py
index be37c24d61..727b0e75f0 100644
--- a/Lib/socket.py
+++ b/Lib/socket.py
@@ -937,7 +937,9 @@ def create_server(address, *, family=AF_INET, backlog=None, reuse_port=False,
# Fail later on bind(), for platforms which may not
# support this option.
pass
- if reuse_port:
+ # Since Linux 6.12.9, SO_REUSEPORT is not allowed
+ # on other address families than AF_INET/AF_INET6.
+ if reuse_port and family in (AF_INET, AF_INET6):
sock.setsockopt(SOL_SOCKET, SO_REUSEPORT, 1)
if has_ipv6 and family == AF_INET6:
if dualstack_ipv6:
diff --git a/Lib/socketserver.py b/Lib/socketserver.py
index cd028ef1c6..35b2723de3 100644
--- a/Lib/socketserver.py
+++ b/Lib/socketserver.py
@@ -468,7 +468,12 @@ def server_bind(self):
"""
if self.allow_reuse_address and hasattr(socket, "SO_REUSEADDR"):
self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
- if self.allow_reuse_port and hasattr(socket, "SO_REUSEPORT"):
+ # Since Linux 6.12.9, SO_REUSEPORT is not allowed
+ # on other address families than AF_INET/AF_INET6.
+ if (
+ self.allow_reuse_port and hasattr(socket, "SO_REUSEPORT")
+ and self.address_family in (socket.AF_INET, socket.AF_INET6)
+ ):
self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1)
self.socket.bind(self.server_address)
self.server_address = self.socket.getsockname()
diff --git a/Misc/NEWS.d/next/Library/2025-01-17-11-46-16.gh-issue-128916.GEePbO.rst b/Misc/NEWS.d/next/Library/2025-01-17-11-46-16.gh-issue-128916.GEePbO.rst
new file mode 100644
index 0000000000..f2db341ef8
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2025-01-17-11-46-16.gh-issue-128916.GEePbO.rst
@@ -0,0 +1,3 @@
+Do not attempt to set ``SO_REUSEPORT`` on sockets of address families
+other than ``AF_INET`` and ``AF_INET6``, as it is meaningless with these
+address families, and the call with fail with Linux kernel 6.12.9 and newer.

View file

@ -1,758 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Petr Viktorin <encukou@gmail.com>
Date: Tue, 21 Jan 2025 16:29:02 +0100
Subject: [PATCH] 00449: gh-128889: Zero out memory ctypes for generated struct
layout tests (GH-128944)
---
.../test_ctypes/test_generated_structs.py | 5 +-
Modules/_ctypes/_ctypes_test_generated.c.h | 216 ++++++++++++------
2 files changed, 147 insertions(+), 74 deletions(-)
diff --git a/Lib/test/test_ctypes/test_generated_structs.py b/Lib/test/test_ctypes/test_generated_structs.py
index d61754d6d4..1df9f0dc16 100644
--- a/Lib/test/test_ctypes/test_generated_structs.py
+++ b/Lib/test/test_ctypes/test_generated_structs.py
@@ -443,7 +443,7 @@ def test_generated_data(self):
- None
- reason to skip the test (str)
- This does depend on the C compiler keeping padding bits zero.
+ This does depend on the C compiler keeping padding bits unchanged.
Common compilers seem to do so.
"""
for name, cls in TESTCASES.items():
@@ -696,7 +696,8 @@ def output(string):
output(' ' + line)
typename = f'{struct_or_union(cls)} {name}'
output(f"""
- {typename} value = {{0}};
+ {typename} value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString({c_str_repr(name)}));
APPEND(PyLong_FromLong(sizeof({typename})));
APPEND(PyLong_FromLong(_Alignof({typename})));
diff --git a/Modules/_ctypes/_ctypes_test_generated.c.h b/Modules/_ctypes/_ctypes_test_generated.c.h
index 46a3e4b01e..d70b33eaa8 100644
--- a/Modules/_ctypes/_ctypes_test_generated.c.h
+++ b/Modules/_ctypes/_ctypes_test_generated.c.h
@@ -56,7 +56,8 @@
struct SingleInt {
int a;
};
- struct SingleInt value = {0};
+ struct SingleInt value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("SingleInt"));
APPEND(PyLong_FromLong(sizeof(struct SingleInt)));
APPEND(PyLong_FromLong(_Alignof(struct SingleInt)));
@@ -69,7 +70,8 @@
union SingleInt_Union {
int a;
};
- union SingleInt_Union value = {0};
+ union SingleInt_Union value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("SingleInt_Union"));
APPEND(PyLong_FromLong(sizeof(union SingleInt_Union)));
APPEND(PyLong_FromLong(_Alignof(union SingleInt_Union)));
@@ -82,7 +84,8 @@
struct SingleU32 {
uint32_t a;
};
- struct SingleU32 value = {0};
+ struct SingleU32 value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("SingleU32"));
APPEND(PyLong_FromLong(sizeof(struct SingleU32)));
APPEND(PyLong_FromLong(_Alignof(struct SingleU32)));
@@ -97,7 +100,8 @@
int8_t y;
uint16_t z;
};
- struct SimpleStruct value = {0};
+ struct SimpleStruct value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("SimpleStruct"));
APPEND(PyLong_FromLong(sizeof(struct SimpleStruct)));
APPEND(PyLong_FromLong(_Alignof(struct SimpleStruct)));
@@ -114,7 +118,8 @@
int8_t y;
uint16_t z;
};
- union SimpleUnion value = {0};
+ union SimpleUnion value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("SimpleUnion"));
APPEND(PyLong_FromLong(sizeof(union SimpleUnion)));
APPEND(PyLong_FromLong(_Alignof(union SimpleUnion)));
@@ -136,7 +141,8 @@
int64_t i64;
uint64_t u64;
};
- struct ManyTypes value = {0};
+ struct ManyTypes value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("ManyTypes"));
APPEND(PyLong_FromLong(sizeof(struct ManyTypes)));
APPEND(PyLong_FromLong(_Alignof(struct ManyTypes)));
@@ -163,7 +169,8 @@
int64_t i64;
uint64_t u64;
};
- union ManyTypesU value = {0};
+ union ManyTypesU value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("ManyTypesU"));
APPEND(PyLong_FromLong(sizeof(union ManyTypesU)));
APPEND(PyLong_FromLong(_Alignof(union ManyTypesU)));
@@ -197,7 +204,8 @@
uint16_t z;
};
};
- struct Nested value = {0};
+ struct Nested value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("Nested"));
APPEND(PyLong_FromLong(sizeof(struct Nested)));
APPEND(PyLong_FromLong(_Alignof(struct Nested)));
@@ -223,7 +231,8 @@
int64_t b;
};
#pragma pack(pop)
- struct Packed1 value = {0};
+ struct Packed1 value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("Packed1"));
APPEND(PyLong_FromLong(sizeof(struct Packed1)));
APPEND(PyLong_FromLong(_Alignof(struct Packed1)));
@@ -247,7 +256,8 @@
int64_t b;
};
#pragma pack(pop)
- struct Packed2 value = {0};
+ struct Packed2 value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("Packed2"));
APPEND(PyLong_FromLong(sizeof(struct Packed2)));
APPEND(PyLong_FromLong(_Alignof(struct Packed2)));
@@ -271,7 +281,8 @@
int64_t b;
};
#pragma pack(pop)
- struct Packed3 value = {0};
+ struct Packed3 value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("Packed3"));
APPEND(PyLong_FromLong(sizeof(struct Packed3)));
APPEND(PyLong_FromLong(_Alignof(struct Packed3)));
@@ -295,7 +306,8 @@
int64_t b;
};
#pragma pack(pop)
- struct Packed4 value = {0};
+ struct Packed4 value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("Packed4"));
APPEND(PyLong_FromLong(sizeof(struct Packed4)));
APPEND(PyLong_FromLong(_Alignof(struct Packed4)));
@@ -316,7 +328,8 @@
int64_t b;
int32_t c;
};
- struct X86_32EdgeCase value = {0};
+ struct X86_32EdgeCase value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("X86_32EdgeCase"));
APPEND(PyLong_FromLong(sizeof(struct X86_32EdgeCase)));
APPEND(PyLong_FromLong(_Alignof(struct X86_32EdgeCase)));
@@ -333,7 +346,8 @@
unsigned int b :5;
unsigned int c :7;
};
- struct MSBitFieldExample value = {0};
+ struct MSBitFieldExample value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("MSBitFieldExample"));
APPEND(PyLong_FromLong(sizeof(struct MSBitFieldExample)));
APPEND(PyLong_FromLong(_Alignof(struct MSBitFieldExample)));
@@ -351,7 +365,8 @@
unsigned int may_straddle :30;
unsigned int last :18;
};
- struct MSStraddlingExample value = {0};
+ struct MSStraddlingExample value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("MSStraddlingExample"));
APPEND(PyLong_FromLong(sizeof(struct MSStraddlingExample)));
APPEND(PyLong_FromLong(_Alignof(struct MSStraddlingExample)));
@@ -375,7 +390,8 @@
int H :8;
int I :9;
};
- struct IntBits value = {0};
+ struct IntBits value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("IntBits"));
APPEND(PyLong_FromLong(sizeof(struct IntBits)));
APPEND(PyLong_FromLong(_Alignof(struct IntBits)));
@@ -413,7 +429,8 @@
short R :6;
short S :7;
};
- struct Bits value = {0};
+ struct Bits value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("Bits"));
APPEND(PyLong_FromLong(sizeof(struct Bits)));
APPEND(PyLong_FromLong(_Alignof(struct Bits)));
@@ -456,7 +473,8 @@
int H :8;
int I :9;
};
- struct IntBits_MSVC value = {0};
+ struct IntBits_MSVC value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("IntBits_MSVC"));
APPEND(PyLong_FromLong(sizeof(struct IntBits_MSVC)));
APPEND(PyLong_FromLong(_Alignof(struct IntBits_MSVC)));
@@ -499,7 +517,8 @@
short R :6;
short S :7;
};
- struct Bits_MSVC value = {0};
+ struct Bits_MSVC value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("Bits_MSVC"));
APPEND(PyLong_FromLong(sizeof(struct Bits_MSVC)));
APPEND(PyLong_FromLong(_Alignof(struct Bits_MSVC)));
@@ -536,7 +555,8 @@
int64_t b :62;
int64_t c :1;
};
- struct I64Bits value = {0};
+ struct I64Bits value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("I64Bits"));
APPEND(PyLong_FromLong(sizeof(struct I64Bits)));
APPEND(PyLong_FromLong(_Alignof(struct I64Bits)));
@@ -560,7 +580,8 @@
uint64_t b :62;
uint64_t c :1;
};
- struct U64Bits value = {0};
+ struct U64Bits value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("U64Bits"));
APPEND(PyLong_FromLong(sizeof(struct U64Bits)));
APPEND(PyLong_FromLong(_Alignof(struct U64Bits)));
@@ -584,7 +605,8 @@
int8_t b :3;
int8_t c :1;
};
- struct Struct331_8 value = {0};
+ struct Struct331_8 value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("Struct331_8"));
APPEND(PyLong_FromLong(sizeof(struct Struct331_8)));
APPEND(PyLong_FromLong(_Alignof(struct Struct331_8)));
@@ -608,7 +630,8 @@
int8_t b :6;
int8_t c :1;
};
- struct Struct1x1_8 value = {0};
+ struct Struct1x1_8 value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("Struct1x1_8"));
APPEND(PyLong_FromLong(sizeof(struct Struct1x1_8)));
APPEND(PyLong_FromLong(_Alignof(struct Struct1x1_8)));
@@ -633,7 +656,8 @@
int8_t b :6;
int8_t c :1;
};
- struct Struct1nx1_8 value = {0};
+ struct Struct1nx1_8 value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("Struct1nx1_8"));
APPEND(PyLong_FromLong(sizeof(struct Struct1nx1_8)));
APPEND(PyLong_FromLong(_Alignof(struct Struct1nx1_8)));
@@ -658,7 +682,8 @@
int8_t b :6;
int8_t c :6;
};
- struct Struct3xx_8 value = {0};
+ struct Struct3xx_8 value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("Struct3xx_8"));
APPEND(PyLong_FromLong(sizeof(struct Struct3xx_8)));
APPEND(PyLong_FromLong(_Alignof(struct Struct3xx_8)));
@@ -682,7 +707,8 @@
uint8_t b :3;
uint8_t c :1;
};
- struct Struct331_u8 value = {0};
+ struct Struct331_u8 value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("Struct331_u8"));
APPEND(PyLong_FromLong(sizeof(struct Struct331_u8)));
APPEND(PyLong_FromLong(_Alignof(struct Struct331_u8)));
@@ -706,7 +732,8 @@
uint8_t b :6;
uint8_t c :1;
};
- struct Struct1x1_u8 value = {0};
+ struct Struct1x1_u8 value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("Struct1x1_u8"));
APPEND(PyLong_FromLong(sizeof(struct Struct1x1_u8)));
APPEND(PyLong_FromLong(_Alignof(struct Struct1x1_u8)));
@@ -731,7 +758,8 @@
uint8_t b :6;
uint8_t c :1;
};
- struct Struct1nx1_u8 value = {0};
+ struct Struct1nx1_u8 value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("Struct1nx1_u8"));
APPEND(PyLong_FromLong(sizeof(struct Struct1nx1_u8)));
APPEND(PyLong_FromLong(_Alignof(struct Struct1nx1_u8)));
@@ -756,7 +784,8 @@
uint8_t b :6;
uint8_t c :6;
};
- struct Struct3xx_u8 value = {0};
+ struct Struct3xx_u8 value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("Struct3xx_u8"));
APPEND(PyLong_FromLong(sizeof(struct Struct3xx_u8)));
APPEND(PyLong_FromLong(_Alignof(struct Struct3xx_u8)));
@@ -780,7 +809,8 @@
int16_t b :3;
int16_t c :1;
};
- struct Struct331_16 value = {0};
+ struct Struct331_16 value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("Struct331_16"));
APPEND(PyLong_FromLong(sizeof(struct Struct331_16)));
APPEND(PyLong_FromLong(_Alignof(struct Struct331_16)));
@@ -804,7 +834,8 @@
int16_t b :14;
int16_t c :1;
};
- struct Struct1x1_16 value = {0};
+ struct Struct1x1_16 value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("Struct1x1_16"));
APPEND(PyLong_FromLong(sizeof(struct Struct1x1_16)));
APPEND(PyLong_FromLong(_Alignof(struct Struct1x1_16)));
@@ -829,7 +860,8 @@
int16_t b :14;
int16_t c :1;
};
- struct Struct1nx1_16 value = {0};
+ struct Struct1nx1_16 value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("Struct1nx1_16"));
APPEND(PyLong_FromLong(sizeof(struct Struct1nx1_16)));
APPEND(PyLong_FromLong(_Alignof(struct Struct1nx1_16)));
@@ -854,7 +886,8 @@
int16_t b :14;
int16_t c :14;
};
- struct Struct3xx_16 value = {0};
+ struct Struct3xx_16 value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("Struct3xx_16"));
APPEND(PyLong_FromLong(sizeof(struct Struct3xx_16)));
APPEND(PyLong_FromLong(_Alignof(struct Struct3xx_16)));
@@ -878,7 +911,8 @@
uint16_t b :3;
uint16_t c :1;
};
- struct Struct331_u16 value = {0};
+ struct Struct331_u16 value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("Struct331_u16"));
APPEND(PyLong_FromLong(sizeof(struct Struct331_u16)));
APPEND(PyLong_FromLong(_Alignof(struct Struct331_u16)));
@@ -902,7 +936,8 @@
uint16_t b :14;
uint16_t c :1;
};
- struct Struct1x1_u16 value = {0};
+ struct Struct1x1_u16 value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("Struct1x1_u16"));
APPEND(PyLong_FromLong(sizeof(struct Struct1x1_u16)));
APPEND(PyLong_FromLong(_Alignof(struct Struct1x1_u16)));
@@ -927,7 +962,8 @@
uint16_t b :14;
uint16_t c :1;
};
- struct Struct1nx1_u16 value = {0};
+ struct Struct1nx1_u16 value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("Struct1nx1_u16"));
APPEND(PyLong_FromLong(sizeof(struct Struct1nx1_u16)));
APPEND(PyLong_FromLong(_Alignof(struct Struct1nx1_u16)));
@@ -952,7 +988,8 @@
uint16_t b :14;
uint16_t c :14;
};
- struct Struct3xx_u16 value = {0};
+ struct Struct3xx_u16 value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("Struct3xx_u16"));
APPEND(PyLong_FromLong(sizeof(struct Struct3xx_u16)));
APPEND(PyLong_FromLong(_Alignof(struct Struct3xx_u16)));
@@ -976,7 +1013,8 @@
int32_t b :3;
int32_t c :1;
};
- struct Struct331_32 value = {0};
+ struct Struct331_32 value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("Struct331_32"));
APPEND(PyLong_FromLong(sizeof(struct Struct331_32)));
APPEND(PyLong_FromLong(_Alignof(struct Struct331_32)));
@@ -1000,7 +1038,8 @@
int32_t b :30;
int32_t c :1;
};
- struct Struct1x1_32 value = {0};
+ struct Struct1x1_32 value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("Struct1x1_32"));
APPEND(PyLong_FromLong(sizeof(struct Struct1x1_32)));
APPEND(PyLong_FromLong(_Alignof(struct Struct1x1_32)));
@@ -1025,7 +1064,8 @@
int32_t b :30;
int32_t c :1;
};
- struct Struct1nx1_32 value = {0};
+ struct Struct1nx1_32 value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("Struct1nx1_32"));
APPEND(PyLong_FromLong(sizeof(struct Struct1nx1_32)));
APPEND(PyLong_FromLong(_Alignof(struct Struct1nx1_32)));
@@ -1050,7 +1090,8 @@
int32_t b :30;
int32_t c :30;
};
- struct Struct3xx_32 value = {0};
+ struct Struct3xx_32 value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("Struct3xx_32"));
APPEND(PyLong_FromLong(sizeof(struct Struct3xx_32)));
APPEND(PyLong_FromLong(_Alignof(struct Struct3xx_32)));
@@ -1074,7 +1115,8 @@
uint32_t b :3;
uint32_t c :1;
};
- struct Struct331_u32 value = {0};
+ struct Struct331_u32 value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("Struct331_u32"));
APPEND(PyLong_FromLong(sizeof(struct Struct331_u32)));
APPEND(PyLong_FromLong(_Alignof(struct Struct331_u32)));
@@ -1098,7 +1140,8 @@
uint32_t b :30;
uint32_t c :1;
};
- struct Struct1x1_u32 value = {0};
+ struct Struct1x1_u32 value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("Struct1x1_u32"));
APPEND(PyLong_FromLong(sizeof(struct Struct1x1_u32)));
APPEND(PyLong_FromLong(_Alignof(struct Struct1x1_u32)));
@@ -1123,7 +1166,8 @@
uint32_t b :30;
uint32_t c :1;
};
- struct Struct1nx1_u32 value = {0};
+ struct Struct1nx1_u32 value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("Struct1nx1_u32"));
APPEND(PyLong_FromLong(sizeof(struct Struct1nx1_u32)));
APPEND(PyLong_FromLong(_Alignof(struct Struct1nx1_u32)));
@@ -1148,7 +1192,8 @@
uint32_t b :30;
uint32_t c :30;
};
- struct Struct3xx_u32 value = {0};
+ struct Struct3xx_u32 value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("Struct3xx_u32"));
APPEND(PyLong_FromLong(sizeof(struct Struct3xx_u32)));
APPEND(PyLong_FromLong(_Alignof(struct Struct3xx_u32)));
@@ -1172,7 +1217,8 @@
int64_t b :3;
int64_t c :1;
};
- struct Struct331_64 value = {0};
+ struct Struct331_64 value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("Struct331_64"));
APPEND(PyLong_FromLong(sizeof(struct Struct331_64)));
APPEND(PyLong_FromLong(_Alignof(struct Struct331_64)));
@@ -1196,7 +1242,8 @@
int64_t b :62;
int64_t c :1;
};
- struct Struct1x1_64 value = {0};
+ struct Struct1x1_64 value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("Struct1x1_64"));
APPEND(PyLong_FromLong(sizeof(struct Struct1x1_64)));
APPEND(PyLong_FromLong(_Alignof(struct Struct1x1_64)));
@@ -1221,7 +1268,8 @@
int64_t b :62;
int64_t c :1;
};
- struct Struct1nx1_64 value = {0};
+ struct Struct1nx1_64 value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("Struct1nx1_64"));
APPEND(PyLong_FromLong(sizeof(struct Struct1nx1_64)));
APPEND(PyLong_FromLong(_Alignof(struct Struct1nx1_64)));
@@ -1246,7 +1294,8 @@
int64_t b :62;
int64_t c :62;
};
- struct Struct3xx_64 value = {0};
+ struct Struct3xx_64 value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("Struct3xx_64"));
APPEND(PyLong_FromLong(sizeof(struct Struct3xx_64)));
APPEND(PyLong_FromLong(_Alignof(struct Struct3xx_64)));
@@ -1270,7 +1319,8 @@
uint64_t b :3;
uint64_t c :1;
};
- struct Struct331_u64 value = {0};
+ struct Struct331_u64 value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("Struct331_u64"));
APPEND(PyLong_FromLong(sizeof(struct Struct331_u64)));
APPEND(PyLong_FromLong(_Alignof(struct Struct331_u64)));
@@ -1294,7 +1344,8 @@
uint64_t b :62;
uint64_t c :1;
};
- struct Struct1x1_u64 value = {0};
+ struct Struct1x1_u64 value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("Struct1x1_u64"));
APPEND(PyLong_FromLong(sizeof(struct Struct1x1_u64)));
APPEND(PyLong_FromLong(_Alignof(struct Struct1x1_u64)));
@@ -1319,7 +1370,8 @@
uint64_t b :62;
uint64_t c :1;
};
- struct Struct1nx1_u64 value = {0};
+ struct Struct1nx1_u64 value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("Struct1nx1_u64"));
APPEND(PyLong_FromLong(sizeof(struct Struct1nx1_u64)));
APPEND(PyLong_FromLong(_Alignof(struct Struct1nx1_u64)));
@@ -1344,7 +1396,8 @@
uint64_t b :62;
uint64_t c :62;
};
- struct Struct3xx_u64 value = {0};
+ struct Struct3xx_u64 value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("Struct3xx_u64"));
APPEND(PyLong_FromLong(sizeof(struct Struct3xx_u64)));
APPEND(PyLong_FromLong(_Alignof(struct Struct3xx_u64)));
@@ -1367,7 +1420,8 @@
signed char a :4;
int b :4;
};
- struct Mixed1 value = {0};
+ struct Mixed1 value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("Mixed1"));
APPEND(PyLong_FromLong(sizeof(struct Mixed1)));
APPEND(PyLong_FromLong(_Alignof(struct Mixed1)));
@@ -1389,7 +1443,8 @@
signed char a :4;
int32_t b :32;
};
- struct Mixed2 value = {0};
+ struct Mixed2 value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("Mixed2"));
APPEND(PyLong_FromLong(sizeof(struct Mixed2)));
APPEND(PyLong_FromLong(_Alignof(struct Mixed2)));
@@ -1411,7 +1466,8 @@
signed char a :4;
unsigned char b :4;
};
- struct Mixed3 value = {0};
+ struct Mixed3 value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("Mixed3"));
APPEND(PyLong_FromLong(sizeof(struct Mixed3)));
APPEND(PyLong_FromLong(_Alignof(struct Mixed3)));
@@ -1437,7 +1493,8 @@
short e :4;
int f :24;
};
- struct Mixed4 value = {0};
+ struct Mixed4 value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("Mixed4"));
APPEND(PyLong_FromLong(sizeof(struct Mixed4)));
APPEND(PyLong_FromLong(_Alignof(struct Mixed4)));
@@ -1463,7 +1520,8 @@
unsigned int A :1;
unsigned short B :16;
};
- struct Mixed5 value = {0};
+ struct Mixed5 value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("Mixed5"));
APPEND(PyLong_FromLong(sizeof(struct Mixed5)));
APPEND(PyLong_FromLong(_Alignof(struct Mixed5)));
@@ -1485,7 +1543,8 @@
unsigned long long A :1;
unsigned int B :32;
};
- struct Mixed6 value = {0};
+ struct Mixed6 value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("Mixed6"));
APPEND(PyLong_FromLong(sizeof(struct Mixed6)));
APPEND(PyLong_FromLong(_Alignof(struct Mixed6)));
@@ -1508,7 +1567,8 @@
uint32_t B :20;
uint64_t C :24;
};
- struct Mixed7 value = {0};
+ struct Mixed7 value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("Mixed7"));
APPEND(PyLong_FromLong(sizeof(struct Mixed7)));
APPEND(PyLong_FromLong(_Alignof(struct Mixed7)));
@@ -1532,7 +1592,8 @@
uint32_t B :32;
unsigned long long C :1;
};
- struct Mixed8_a value = {0};
+ struct Mixed8_a value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("Mixed8_a"));
APPEND(PyLong_FromLong(sizeof(struct Mixed8_a)));
APPEND(PyLong_FromLong(_Alignof(struct Mixed8_a)));
@@ -1556,7 +1617,8 @@
uint32_t B;
unsigned long long C :1;
};
- struct Mixed8_b value = {0};
+ struct Mixed8_b value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("Mixed8_b"));
APPEND(PyLong_FromLong(sizeof(struct Mixed8_b)));
APPEND(PyLong_FromLong(_Alignof(struct Mixed8_b)));
@@ -1579,7 +1641,8 @@
uint8_t A;
uint32_t B :1;
};
- struct Mixed9 value = {0};
+ struct Mixed9 value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("Mixed9"));
APPEND(PyLong_FromLong(sizeof(struct Mixed9)));
APPEND(PyLong_FromLong(_Alignof(struct Mixed9)));
@@ -1601,7 +1664,8 @@
uint32_t A :1;
uint64_t B :1;
};
- struct Mixed10 value = {0};
+ struct Mixed10 value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("Mixed10"));
APPEND(PyLong_FromLong(sizeof(struct Mixed10)));
APPEND(PyLong_FromLong(_Alignof(struct Mixed10)));
@@ -1623,7 +1687,8 @@
uint32_t A :1;
uint64_t B :1;
};
- struct Example_gh_95496 value = {0};
+ struct Example_gh_95496 value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("Example_gh_95496"));
APPEND(PyLong_FromLong(sizeof(struct Example_gh_95496)));
APPEND(PyLong_FromLong(_Alignof(struct Example_gh_95496)));
@@ -1655,7 +1720,8 @@
uint16_t b1 :12;
};
#pragma pack(pop)
- struct Example_gh_84039_bad value = {0};
+ struct Example_gh_84039_bad value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("Example_gh_84039_bad"));
APPEND(PyLong_FromLong(sizeof(struct Example_gh_84039_bad)));
APPEND(PyLong_FromLong(_Alignof(struct Example_gh_84039_bad)));
@@ -1693,7 +1759,8 @@
uint8_t a7 :1;
};
#pragma pack(pop)
- struct Example_gh_84039_good_a value = {0};
+ struct Example_gh_84039_good_a value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("Example_gh_84039_good_a"));
APPEND(PyLong_FromLong(sizeof(struct Example_gh_84039_good_a)));
APPEND(PyLong_FromLong(_Alignof(struct Example_gh_84039_good_a)));
@@ -1735,7 +1802,8 @@
uint16_t b1 :12;
};
#pragma pack(pop)
- struct Example_gh_84039_good value = {0};
+ struct Example_gh_84039_good value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("Example_gh_84039_good"));
APPEND(PyLong_FromLong(sizeof(struct Example_gh_84039_good)));
APPEND(PyLong_FromLong(_Alignof(struct Example_gh_84039_good)));
@@ -1775,7 +1843,8 @@
uint32_t R2 :2;
};
#pragma pack(pop)
- struct Example_gh_73939 value = {0};
+ struct Example_gh_73939 value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("Example_gh_73939"));
APPEND(PyLong_FromLong(sizeof(struct Example_gh_73939)));
APPEND(PyLong_FromLong(_Alignof(struct Example_gh_73939)));
@@ -1806,7 +1875,8 @@
uint8_t b :8;
uint32_t c :16;
};
- struct Example_gh_86098 value = {0};
+ struct Example_gh_86098 value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("Example_gh_86098"));
APPEND(PyLong_FromLong(sizeof(struct Example_gh_86098)));
APPEND(PyLong_FromLong(_Alignof(struct Example_gh_86098)));
@@ -1832,7 +1902,8 @@
uint32_t c :16;
};
#pragma pack(pop)
- struct Example_gh_86098_pack value = {0};
+ struct Example_gh_86098_pack value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("Example_gh_86098_pack"));
APPEND(PyLong_FromLong(sizeof(struct Example_gh_86098_pack)));
APPEND(PyLong_FromLong(_Alignof(struct Example_gh_86098_pack)));
@@ -1858,7 +1929,8 @@
};
signed char y;
};
- struct AnonBitfields value = {0};
+ struct AnonBitfields value;
+ memset(&value, 0, sizeof(value));
APPEND(PyUnicode_FromString("AnonBitfields"));
APPEND(PyLong_FromLong(sizeof(struct AnonBitfields)));
APPEND(PyLong_FromLong(_Alignof(struct AnonBitfields)));

View file

@ -1,119 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Seth Michael Larson <seth@python.org>
Date: Fri, 31 Jan 2025 11:41:34 -0600
Subject: [PATCH] 00450: CVE-2025-0938: Disallow square brackets ([ and ]) in
domain names for parsed URLs
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
---
Lib/test/test_urlparse.py | 37 ++++++++++++++++++-
Lib/urllib/parse.py | 20 +++++++++-
...-01-28-14-08-03.gh-issue-105704.EnhHxu.rst | 4 ++
3 files changed, 58 insertions(+), 3 deletions(-)
create mode 100644 Misc/NEWS.d/next/Security/2025-01-28-14-08-03.gh-issue-105704.EnhHxu.rst
diff --git a/Lib/test/test_urlparse.py b/Lib/test/test_urlparse.py
index 4516bdea6a..b51cc006b7 100644
--- a/Lib/test/test_urlparse.py
+++ b/Lib/test/test_urlparse.py
@@ -1412,16 +1412,51 @@ def test_invalid_bracketed_hosts(self):
self.assertRaises(ValueError, urllib.parse.urlsplit, 'Scheme://user@[0439:23af::2309::fae7:1234]/Path?Query')
self.assertRaises(ValueError, urllib.parse.urlsplit, 'Scheme://user@[0439:23af:2309::fae7:1234:2342:438e:192.0.2.146]/Path?Query')
self.assertRaises(ValueError, urllib.parse.urlsplit, 'Scheme://user@]v6a.ip[/Path')
+ self.assertRaises(ValueError, urllib.parse.urlsplit, 'scheme://prefix.[v6a.ip]')
+ self.assertRaises(ValueError, urllib.parse.urlsplit, 'scheme://[v6a.ip].suffix')
+ self.assertRaises(ValueError, urllib.parse.urlsplit, 'scheme://prefix.[v6a.ip]/')
+ self.assertRaises(ValueError, urllib.parse.urlsplit, 'scheme://[v6a.ip].suffix/')
+ self.assertRaises(ValueError, urllib.parse.urlsplit, 'scheme://prefix.[v6a.ip]?')
+ self.assertRaises(ValueError, urllib.parse.urlsplit, 'scheme://[v6a.ip].suffix?')
+ self.assertRaises(ValueError, urllib.parse.urlsplit, 'scheme://prefix.[::1]')
+ self.assertRaises(ValueError, urllib.parse.urlsplit, 'scheme://[::1].suffix')
+ self.assertRaises(ValueError, urllib.parse.urlsplit, 'scheme://prefix.[::1]/')
+ self.assertRaises(ValueError, urllib.parse.urlsplit, 'scheme://[::1].suffix/')
+ self.assertRaises(ValueError, urllib.parse.urlsplit, 'scheme://prefix.[::1]?')
+ self.assertRaises(ValueError, urllib.parse.urlsplit, 'scheme://[::1].suffix?')
+ self.assertRaises(ValueError, urllib.parse.urlsplit, 'scheme://prefix.[::1]:a')
+ self.assertRaises(ValueError, urllib.parse.urlsplit, 'scheme://[::1].suffix:a')
+ self.assertRaises(ValueError, urllib.parse.urlsplit, 'scheme://prefix.[::1]:a1')
+ self.assertRaises(ValueError, urllib.parse.urlsplit, 'scheme://[::1].suffix:a1')
+ self.assertRaises(ValueError, urllib.parse.urlsplit, 'scheme://prefix.[::1]:1a')
+ self.assertRaises(ValueError, urllib.parse.urlsplit, 'scheme://[::1].suffix:1a')
+ self.assertRaises(ValueError, urllib.parse.urlsplit, 'scheme://prefix.[::1]:')
+ self.assertRaises(ValueError, urllib.parse.urlsplit, 'scheme://[::1].suffix:/')
+ self.assertRaises(ValueError, urllib.parse.urlsplit, 'scheme://prefix.[::1]:?')
+ self.assertRaises(ValueError, urllib.parse.urlsplit, 'scheme://user@prefix.[v6a.ip]')
+ self.assertRaises(ValueError, urllib.parse.urlsplit, 'scheme://user@[v6a.ip].suffix')
+ self.assertRaises(ValueError, urllib.parse.urlsplit, 'scheme://[v6a.ip')
+ self.assertRaises(ValueError, urllib.parse.urlsplit, 'scheme://v6a.ip]')
+ self.assertRaises(ValueError, urllib.parse.urlsplit, 'scheme://]v6a.ip[')
+ self.assertRaises(ValueError, urllib.parse.urlsplit, 'scheme://]v6a.ip')
+ self.assertRaises(ValueError, urllib.parse.urlsplit, 'scheme://v6a.ip[')
+ self.assertRaises(ValueError, urllib.parse.urlsplit, 'scheme://prefix.[v6a.ip')
+ self.assertRaises(ValueError, urllib.parse.urlsplit, 'scheme://v6a.ip].suffix')
+ self.assertRaises(ValueError, urllib.parse.urlsplit, 'scheme://prefix]v6a.ip[suffix')
+ self.assertRaises(ValueError, urllib.parse.urlsplit, 'scheme://prefix]v6a.ip')
+ self.assertRaises(ValueError, urllib.parse.urlsplit, 'scheme://v6a.ip[suffix')
def test_splitting_bracketed_hosts(self):
- p1 = urllib.parse.urlsplit('scheme://user@[v6a.ip]/path?query')
+ p1 = urllib.parse.urlsplit('scheme://user@[v6a.ip]:1234/path?query')
self.assertEqual(p1.hostname, 'v6a.ip')
self.assertEqual(p1.username, 'user')
self.assertEqual(p1.path, '/path')
+ self.assertEqual(p1.port, 1234)
p2 = urllib.parse.urlsplit('scheme://user@[0439:23af:2309::fae7%test]/path?query')
self.assertEqual(p2.hostname, '0439:23af:2309::fae7%test')
self.assertEqual(p2.username, 'user')
self.assertEqual(p2.path, '/path')
+ self.assertIs(p2.port, None)
p3 = urllib.parse.urlsplit('scheme://user@[0439:23af:2309::fae7:1234:192.0.2.146%test]/path?query')
self.assertEqual(p3.hostname, '0439:23af:2309::fae7:1234:192.0.2.146%test')
self.assertEqual(p3.username, 'user')
diff --git a/Lib/urllib/parse.py b/Lib/urllib/parse.py
index c412c72985..9d51f4c681 100644
--- a/Lib/urllib/parse.py
+++ b/Lib/urllib/parse.py
@@ -439,6 +439,23 @@ def _checknetloc(netloc):
raise ValueError("netloc '" + netloc + "' contains invalid " +
"characters under NFKC normalization")
+def _check_bracketed_netloc(netloc):
+ # Note that this function must mirror the splitting
+ # done in NetlocResultMixins._hostinfo().
+ hostname_and_port = netloc.rpartition('@')[2]
+ before_bracket, have_open_br, bracketed = hostname_and_port.partition('[')
+ if have_open_br:
+ # No data is allowed before a bracket.
+ if before_bracket:
+ raise ValueError("Invalid IPv6 URL")
+ hostname, _, port = bracketed.partition(']')
+ # No data is allowed after the bracket but before the port delimiter.
+ if port and not port.startswith(":"):
+ raise ValueError("Invalid IPv6 URL")
+ else:
+ hostname, _, port = hostname_and_port.partition(':')
+ _check_bracketed_host(hostname)
+
# Valid bracketed hosts are defined in
# https://www.rfc-editor.org/rfc/rfc3986#page-49 and https://url.spec.whatwg.org/
def _check_bracketed_host(hostname):
@@ -505,8 +522,7 @@ def _urlsplit(url, scheme=None, allow_fragments=True):
(']' in netloc and '[' not in netloc)):
raise ValueError("Invalid IPv6 URL")
if '[' in netloc and ']' in netloc:
- bracketed_host = netloc.partition('[')[2].partition(']')[0]
- _check_bracketed_host(bracketed_host)
+ _check_bracketed_netloc(netloc)
if allow_fragments and '#' in url:
url, fragment = url.split('#', 1)
if '?' in url:
diff --git a/Misc/NEWS.d/next/Security/2025-01-28-14-08-03.gh-issue-105704.EnhHxu.rst b/Misc/NEWS.d/next/Security/2025-01-28-14-08-03.gh-issue-105704.EnhHxu.rst
new file mode 100644
index 0000000000..bff1bc6b0d
--- /dev/null
+++ b/Misc/NEWS.d/next/Security/2025-01-28-14-08-03.gh-issue-105704.EnhHxu.rst
@@ -0,0 +1,4 @@
+When using :func:`urllib.parse.urlsplit` and :func:`urllib.parse.urlparse` host
+parsing would not reject domain names containing square brackets (``[`` and
+``]``). Square brackets are only valid for IPv6 and IPvFuture hosts according to
+`RFC 3986 Section 3.2.2 <https://www.rfc-editor.org/rfc/rfc3986#section-3.2.2>`__.

View file

@ -0,0 +1,89 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Sam Gross <colesbury@gmail.com>
Date: Wed, 12 Feb 2025 18:09:15 -0500
Subject: [PATCH] 00451: gh-130030: Fix crash on 32-bit Linux with free
threading (gh-130043)
The `gc_get_refs` assertion needs to be after we check the alive and
unreachable bits. Otherwise, `ob_tid` may store the actual thread id
instead of the computed `gc_refs`, which may trigger the assertion if
the `ob_tid` looks like a negative value.
Also fix a few type warnings on 32-bit systems.
---
Objects/obmalloc.c | 12 ++++++------
Python/gc_free_threading.c | 12 +++++++-----
2 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/Objects/obmalloc.c b/Objects/obmalloc.c
index 5688049b02..6341251007 100644
--- a/Objects/obmalloc.c
+++ b/Objects/obmalloc.c
@@ -3297,12 +3297,12 @@ static bool _collect_alloc_stats(
static void
py_mimalloc_print_stats(FILE *out)
{
- fprintf(out, "Small block threshold = %zd, in %u size classes.\n",
- MI_SMALL_OBJ_SIZE_MAX, MI_BIN_HUGE);
- fprintf(out, "Medium block threshold = %zd\n",
- MI_MEDIUM_OBJ_SIZE_MAX);
- fprintf(out, "Large object max size = %zd\n",
- MI_LARGE_OBJ_SIZE_MAX);
+ fprintf(out, "Small block threshold = %zu, in %u size classes.\n",
+ (size_t)MI_SMALL_OBJ_SIZE_MAX, MI_BIN_HUGE);
+ fprintf(out, "Medium block threshold = %zu\n",
+ (size_t)MI_MEDIUM_OBJ_SIZE_MAX);
+ fprintf(out, "Large object max size = %zu\n",
+ (size_t)MI_LARGE_OBJ_SIZE_MAX);
mi_heap_t *heap = mi_heap_get_default();
struct _alloc_stats stats;
diff --git a/Python/gc_free_threading.c b/Python/gc_free_threading.c
index 9e459da3a4..0d6fddb570 100644
--- a/Python/gc_free_threading.c
+++ b/Python/gc_free_threading.c
@@ -581,11 +581,13 @@ gc_mark_buffer_len(gc_mark_args_t *args)
}
// Returns number of free entry slots in buffer
+#ifndef NDEBUG
static inline unsigned int
gc_mark_buffer_avail(gc_mark_args_t *args)
{
return BUFFER_SIZE - gc_mark_buffer_len(args);
}
+#endif
static inline bool
gc_mark_buffer_is_empty(gc_mark_args_t *args)
@@ -1074,14 +1076,14 @@ mark_heap_visitor(const mi_heap_t *heap, const mi_heap_area_t *area,
return true;
}
- _PyObject_ASSERT_WITH_MSG(op, gc_get_refs(op) >= 0,
- "refcount is too small");
-
if (gc_is_alive(op) || !gc_is_unreachable(op)) {
// Object was already marked as reachable.
return true;
}
+ _PyObject_ASSERT_WITH_MSG(op, gc_get_refs(op) >= 0,
+ "refcount is too small");
+
// GH-129236: If we've seen an active frame without a valid stack pointer,
// then we can't collect objects with deferred references because we may
// have missed some reference to the object on the stack. In that case,
@@ -1178,10 +1180,10 @@ move_legacy_finalizer_reachable(struct collection_state *state);
static void
gc_prime_from_spans(gc_mark_args_t *args)
{
- Py_ssize_t space = BUFFER_HI - gc_mark_buffer_len(args);
+ unsigned int space = BUFFER_HI - gc_mark_buffer_len(args);
// there should always be at least this amount of space
assert(space <= gc_mark_buffer_avail(args));
- assert(space > 0);
+ assert(space <= BUFFER_HI);
gc_span_t entry = args->spans.stack[--args->spans.size];
// spans on the stack should always have one or more elements
assert(entry.start < entry.end);

View file

@ -14,10 +14,10 @@ URL: https://www.python.org/
# WARNING When rebasing to a new Python version,
# remember to update the python3-docs package as well
%global general_version %{pybasever}.0
%global prerel a4
%global prerel a5
%global upstream_version %{general_version}%{?prerel}
Version: %{general_version}%{?prerel:~%{prerel}}
Release: 3%{?dist}
Release: 1%{?dist}
License: Python-2.0.1
@ -57,28 +57,28 @@ License: Python-2.0.1
# This needs to be manually updated when we update Python.
# Explore the sources tarball (you need the version before %%prep is executed):
# $ tar -tf Python-%%{upstream_version}.tar.xz | grep whl
%global pip_version 24.3.1
%global pip_version 25.0.1
%global setuptools_version 67.6.1
%global wheel_version 0.43.0
# All of those also include a list of indirect bundled libs:
# pip
# $ %%{_rpmconfigdir}/pythonbundles.py <(unzip -p Lib/ensurepip/_bundled/pip-*.whl pip/_vendor/vendor.txt)
%global pip_bundled_provides %{expand:
Provides: bundled(python3dist(cachecontrol)) = 0.14
Provides: bundled(python3dist(cachecontrol)) = 0.14.1
Provides: bundled(python3dist(certifi)) = 2024.8.30
Provides: bundled(python3dist(distlib)) = 0.3.9
Provides: bundled(python3dist(distro)) = 1.9
Provides: bundled(python3dist(idna)) = 3.7
Provides: bundled(python3dist(msgpack)) = 1.0.8
Provides: bundled(python3dist(packaging)) = 24.1
Provides: bundled(python3dist(platformdirs)) = 4.2.2
Provides: bundled(python3dist(idna)) = 3.10
Provides: bundled(python3dist(msgpack)) = 1.1
Provides: bundled(python3dist(packaging)) = 24.2
Provides: bundled(python3dist(platformdirs)) = 4.3.6
Provides: bundled(python3dist(pygments)) = 2.18
Provides: bundled(python3dist(pyproject-hooks)) = 1
Provides: bundled(python3dist(pyproject-hooks)) = 1.2
Provides: bundled(python3dist(requests)) = 2.32.3
Provides: bundled(python3dist(resolvelib)) = 1.0.1
Provides: bundled(python3dist(rich)) = 13.7.1
Provides: bundled(python3dist(rich)) = 13.9.4
Provides: bundled(python3dist(setuptools)) = 70.3
Provides: bundled(python3dist(tomli)) = 2.0.1
Provides: bundled(python3dist(tomli)) = 2.2.1
Provides: bundled(python3dist(truststore)) = 0.10
Provides: bundled(python3dist(typing-extensions)) = 4.12.2
Provides: bundled(python3dist(urllib3)) = 1.26.20
@ -351,28 +351,16 @@ Source11: idle3.appdata.xml
# pypa/distutils integration: https://github.com/pypa/distutils/pull/70
Patch251: 00251-change-user-install-location.patch
# 00448 # e145ddea32596809c4222b05444c645eed2ea3af
# gh-128916: Do not set `SO_REUSEPORT` on non-`AF_INET*` sockets (GH-128933)
# 00451 # 6b2c3f979219408cc0d48262c31f14a7da418ae2
# gh-130030: Fix crash on 32-bit Linux with free threading (gh-130043)
#
# * gh-128916: Do not set `SO_REUSEPORT` on non-`AF_INET*` sockets
# The `gc_get_refs` assertion needs to be after we check the alive and
# unreachable bits. Otherwise, `ob_tid` may store the actual thread id
# instead of the computed `gc_refs`, which may trigger the assertion if
# the `ob_tid` looks like a negative value.
#
# Do not attempt to set ``SO_REUSEPORT`` on sockets of address familifies other
# than ``AF_INET`` and ``AF_INET6``, as it is meaningless with these address
# families, and the call with fail with Linux kernel 6.12.9 and newer.
#
# * Apply suggestions from code review
#
#
# ---------
Patch448: 00448-gh-128916-do-not-set-so_reuseport-on-non--af_inet-sockets-gh-128933.patch
# 00449 # ddd832ac88676343c94b57af00f892928d2c242d
# gh-128889: Zero out memory ctypes for generated struct layout tests (GH-128944)
Patch449: 00449-gh-128889-zero-out-memory-ctypes-for-generated-struct-layout-tests-gh-128944.patch
# 00450 # 4ab8663661748eb994c09e4ae89f59eb84c5d3ea
# CVE-2025-0938: Disallow square brackets ([ and ]) in domain names for parsed URLs
Patch450: 00450-cve-2025-0938-disallow-square-brackets-and-in-domain-names-for-parsed-urls.patch
# Also fix a few type warnings on 32-bit systems.
Patch451: 00451-gh-130030-fix-crash-on-32-bit-linux-with-free-threading-gh-130043.patch
# (New patches go here ^^^)
#
@ -1264,8 +1252,8 @@ CheckPython() {
# test.test_concurrent_futures.test_deadlock tends to time out on s390x and ppc64le in
# freethreading{,-debug} build, skipping it to shorten the build time
# see: https://github.com/python/cpython/issues/121719
# test_init_pyvenv_cfg is failing since 3.14.0a4, the issue is known upstream:
# https://github.com/python/cpython/issues/128690
# test_external_inspection sometimes fails on freethreading-debug
# see: https://github.com/python/cpython/issues/130035
LD_LIBRARY_PATH=$ConfDir $ConfDir/python -m test.regrtest \
-wW --slowest %{_smp_mflags} \
%ifarch riscv64
@ -1275,7 +1263,7 @@ CheckPython() {
%endif
-i test_freeze_simple_script \
-i test_check_probes \
-i test_init_pyvenv_cfg \
-i test_external_inspection \
%ifarch %{mips64}
-x test_ctypes \
%endif
@ -1717,6 +1705,9 @@ CheckPython freethreading
# ======================================================
%changelog
* Wed Feb 12 2025 Karolina Surma <ksurma@redhat.com> - 3.14.0~a5-1
- Update to Python 3.14.0a5
* Thu Feb 06 2025 Miro Hrončok <mhroncok@redhat.com> - 3.14.0~a4-3
- Rebuilt with mpdecimal 4.0.0

View file

@ -1 +1 @@
SHA512 (Python-3.14.0a4.tar.xz) = b70671ebbd9f777fdcb661405c538c733600470ac34992a5b3df99d2f5afecc22cd8325eeec50eeef043181e634da91e535c166b9b5ed421d4e6aa41b79da3ab
SHA512 (Python-3.14.0a5.tar.xz) = ae34c994f00c36c6ce18091c63eb3469aa545ee391c6879c89f5722f7311f2e97cc997477897969777dfaf98090e3dd01dcdb655c986140e9a7796f963be9df9