Skip to content

Commit feeff2a

Browse files
generatedunixname1734921407115435meta-codesync[bot]
authored andcommitted
Sync pre-release CPython main branch from GitHub (2026-06-16)
Summary: Imported python/cpython `3.16.0a0` from upstream rev [`11f032f`](https://www.github.com/python/cpython/commit/11f032f904c8019b332a3c367f335e05cde63628) (committed 2026-06-16 04:51:39+00:00). # Commit Info - Base: (`3.16.0a0`) - [`d63c994`](https://www.github.com/python/cpython/commit/d63c9940f0bcc5497c42c6ac2768cdab02300e10) (commit date: 2026-06-14 19:17:45+00:00) - Imported: (`3.16.0a0`) - [`11f032f`](https://www.github.com/python/cpython/commit/11f032f904c8019b332a3c367f335e05cde63628) (commit date: 2026-06-16 04:51:39+00:00) # Noteworthy file changes - Low-signal files (4 added) (NEWS.d, docs, .github) Complete list of added/removed files: https://www.internalfb.com/intern/everpaste/?color=0&handle=GB6Fux96Df_zYSQFAIvSbAVtys1Ebr0LAAAz Differential Revision: D108709491 fbshipit-source-id: 788e39065e47524d74e1f1ddb6d7c11b7e66f3ce
1 parent 39ce622 commit feeff2a

34 files changed

Lines changed: 245 additions & 115 deletions

.editorconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
root = true
22

3-
[*.{py,c,cpp,h,js,rst,md,yml,yaml,gram}]
3+
[*.{py,c,cpp,h,js,rst,md,yml,yaml,toml,gram}]
44
trim_trailing_whitespace = true
55
insert_final_newline = true
66
indent_style = space
77

8-
[*.{py,c,cpp,h,gram}]
8+
[*.{py,c,cpp,h,toml,gram}]
99
indent_size = 4
1010

1111
[*.rst]

Doc/library/mimetypes.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ the information :func:`init` sets up.
3939
(e.g. :program:`compress` or :program:`gzip`). The encoding is suitable for use
4040
as a :mailheader:`Content-Encoding` header, **not** as a
4141
:mailheader:`Content-Transfer-Encoding` header. The mappings are table driven.
42-
Encoding suffixes are case sensitive; type suffixes are first tried case
43-
sensitively, then case insensitively.
42+
Encoding suffixes are case-sensitive. Suffix mappings and type suffixes are
43+
first tried case-sensitively, then case-insensitively.
4444

4545
The optional *strict* argument is a flag specifying whether the list of known MIME types
4646
is limited to only the official types `registered with IANA
@@ -131,6 +131,8 @@ behavior of the module.
131131
is already known the extension will be added to the list of known extensions.
132132
Valid extensions are empty or start with a ``'.'``.
133133

134+
Registered lower-case extensions are matched case-insensitively.
135+
134136
When *strict* is ``True`` (the default), the mapping will be added to the
135137
official MIME types, otherwise to the non-standard ones.
136138

@@ -312,6 +314,8 @@ than one MIME-type database; it provides an interface similar to the one of the
312314
extension is already known, the new type will replace the old one. When the type
313315
is already known the extension will be added to the list of known extensions.
314316

317+
Registered lower-case extensions are matched case-insensitively.
318+
315319
When *strict* is ``True`` (the default), the mapping will be added to the
316320
official MIME types, otherwise to the non-standard ones.
317321

Include/internal/pycore_interp_structs.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,6 @@ struct _import_runtime_state {
308308
Modules are added there and looked up in _imp.find_extension(). */
309309
struct _Py_hashtable_t *hashtable;
310310
} extensions;
311-
/* Package context -- the full module name for package imports */
312-
const char * pkgcontext;
313311
};
314312

315313
struct _import_state {

Include/internal/pycore_object.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -830,9 +830,14 @@ _PyObject_IS_GC(PyObject *obj)
830830
&& (type->tp_is_gc == NULL || type->tp_is_gc(obj)));
831831
}
832832

833-
// Fast inlined version of PyObject_Hash()
834-
static inline Py_hash_t
835-
_PyObject_HashFast(PyObject *op)
833+
// Fast inlined version of PyObject_Hash(). Dictionaries are very
834+
// likely to include string keys (class and instance attributes,
835+
// json, ...) so we include a fast path for strings.
836+
// This function should not be used in a collection if str is not
837+
// very likely, since it is slower than PyObject_Hash() on types
838+
// other than str. See gh-137759.
839+
static inline Py_ALWAYS_INLINE Py_hash_t
840+
_PyObject_HashDictKey(PyObject *op)
836841
{
837842
if (PyUnicode_CheckExact(op)) {
838843
Py_hash_t hash = PyUnstable_Unicode_GET_CACHED_HASH(op);

Lib/mimetypes.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ def add_type(self, type, ext, strict=True):
8686
is already known the extension will be added
8787
to the list of known extensions.
8888
89+
Registered lower-case extensions are matched
90+
case-insensitively.
91+
8992
If strict is true, information will be added to
9093
list of standard types, else to the list of non-standard
9194
types.
@@ -172,23 +175,33 @@ def guess_file_type(self, path, *, strict=True):
172175

173176
def _guess_file_type(self, path, strict, splitext):
174177
base, ext = splitext(path)
175-
while (ext_lower := ext.lower()) in self.suffix_map:
176-
base, ext = splitext(base + self.suffix_map[ext_lower])
178+
while True:
179+
if ext in self.suffix_map:
180+
suffix = self.suffix_map[ext]
181+
elif (ext_lower := ext.lower()) in self.suffix_map:
182+
suffix = self.suffix_map[ext_lower]
183+
else:
184+
break
185+
base, ext = splitext(base + suffix)
177186
# encodings_map is case sensitive
178187
if ext in self.encodings_map:
179188
encoding = self.encodings_map[ext]
180189
base, ext = splitext(base)
181190
else:
182191
encoding = None
183-
ext = ext.lower()
192+
ext_lower = ext.lower()
184193
types_map = self.types_map[True]
185194
if ext in types_map:
186195
return types_map[ext], encoding
196+
if ext_lower in types_map:
197+
return types_map[ext_lower], encoding
187198
elif strict:
188199
return None, encoding
189200
types_map = self.types_map[False]
190201
if ext in types_map:
191202
return types_map[ext], encoding
203+
if ext_lower in types_map:
204+
return types_map[ext_lower], encoding
192205
else:
193206
return None, encoding
194207

@@ -386,6 +399,9 @@ def add_type(type, ext, strict=True):
386399
is already known the extension will be added
387400
to the list of known extensions.
388401
402+
Registered lower-case extensions are matched
403+
case-insensitively.
404+
389405
If strict is true, information will be added to
390406
list of standard types, else to the list of non-standard
391407
types.

Lib/site.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,11 @@ def _exec_imports(self):
505505
# batch. In that case, PEP 829 says the import lines are
506506
# suppressed in favor of the .start's entry points.
507507
for filename, imports in self._importexecs.items():
508+
# Inject 'sitedir' local variable in the current frame for
509+
# compatibility with Python 3.14. Especially, "-nspkg.pth" files
510+
# generated by setuptools use: sys._getframe(1).f_locals['sitedir'].
511+
sitedir = os.path.dirname(filename)
512+
508513
# Given "/path/to/foo.pth", check whether "/path/to/foo.start" was
509514
# registered in this same batch.
510515
name, dot, pth = filename.rpartition(".")

Lib/test/support/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3159,7 +3159,7 @@ def in_systemd_nspawn_sync_suppressed() -> bool:
31593159
with open("/run/systemd/container", "rb") as fp:
31603160
if fp.read().rstrip() != b"systemd-nspawn":
31613161
return False
3162-
except FileNotFoundError:
3162+
except (FileNotFoundError, PermissionError):
31633163
return False
31643164

31653165
# If systemd-nspawn is used, O_SYNC flag will immediately

Lib/test/test_asyncio/test_ssl.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1544,6 +1544,9 @@ async def client(addr):
15441544
# This triggers bug gh-115514, also tested using mocks in
15451545
# test.test_asyncio.test_selector_events.SelectorSocketTransportTests.test_write_buffer_after_close
15461546
socket_transport = writer.transport._ssl_protocol._transport
1547+
# connection_lost may have already cleared _transport.
1548+
if socket_transport is None:
1549+
return
15471550

15481551
class SocketWrapper:
15491552
def __init__(self, sock) -> None:

Lib/test/test_ctypes/test_as_parameter.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
c_short, c_int, c_long, c_longlong,
66
c_byte, c_wchar, c_float, c_double,
77
ArgumentError)
8-
from test.support import import_helper, skip_if_sanitizer
8+
from test.support import import_helper, skip_if_sanitizer, skip_emscripten_stack_overflow
99
_ctypes_test = import_helper.import_module("_ctypes_test")
1010

1111

@@ -193,6 +193,7 @@ class S8I(Structure):
193193
(9*2, 8*3, 7*4, 6*5, 5*6, 4*7, 3*8, 2*9))
194194

195195
@skip_if_sanitizer('requires deep stack', thread=True)
196+
@skip_emscripten_stack_overflow()
196197
def test_recursive_as_param(self):
197198
class A:
198199
pass

Lib/test/test_ctypes/test_structures.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,9 +299,16 @@ class X(Structure):
299299
self.assertEqual(s.first, got.first)
300300
self.assertEqual(s.second, got.second)
301301

302+
@unittest.skipIf(support.is_wasm32, "wasm ABI is incompatible with test expectations")
302303
def _test_issue18060(self, Vector):
303304
# Regression tests for gh-62260
304305

306+
# This test passes a struct of two doubles by value to atan2(), whose C
307+
# signature is atan2(double, double), so it only works on platforms
308+
# where the abi of a function that takes a struct with two doubles
309+
# matches the abi of a function that takes two doubles. The wasm32 ABI
310+
# does not satisfy this condition and the test breaks.
311+
305312
# The call to atan2() should succeed if the
306313
# class fields were correctly cloned in the
307314
# subclasses. Otherwise, it will segfault.

0 commit comments

Comments
 (0)