Skip to content

Commit b60961f

Browse files
authored
Merge branch 'main' into patch-1
2 parents 81c8475 + 5ea1e90 commit b60961f

56 files changed

Lines changed: 359 additions & 188 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.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

Doc/library/warnings.rst

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -626,9 +626,28 @@ Available Context Managers
626626
If the *record* argument is :const:`False` (the default) the context manager
627627
returns :class:`None` on entry. If *record* is :const:`True`, a list is
628628
returned that is progressively populated with objects as seen by a custom
629-
:func:`showwarning` function (which also suppresses output to ``sys.stdout``).
630-
Each object in the list has attributes with the same names as the arguments to
631-
:func:`showwarning`.
629+
:func:`showwarning` function (which also suppresses output to ``sys.stderr``).
630+
Each object in the list is guaranteed to have the following attributes:
631+
632+
- ``message``: the warning message (an instance of :exc:`Warning`)
633+
- ``category``: the warning category (a subclass of :exc:`Warning`)
634+
- ``filename``: the file name where the warning occurred (:class:`str`)
635+
- ``lineno``: the line number in the file (:class:`int`)
636+
- ``file``: the file object used for output (if any), or ``None``
637+
- ``line``: the line of source code (if available), or ``None``
638+
- ``source``: the original object that generated the warning (if
639+
available), or ``None``
640+
- ``module``: the module name where the warning occurred
641+
(:class:`str`), or ``None``
642+
643+
.. versionchanged:: 3.6
644+
The ``source`` attribute was added.
645+
646+
.. versionchanged:: 3.15
647+
The ``module`` attribute was added.
648+
649+
The type of these objects is not specified and may change; only the
650+
presence of these attributes is guaranteed.
632651

633652
The *module* argument takes a module that will be used instead of the
634653
module returned when you import :mod:`!warnings` whose filter will be

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/_pyrepl/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ def is_soft_keyword_used(*tokens: TI | None) -> bool:
259259
None | TI(T.NEWLINE) | TI(T.INDENT) | TI(string=":"),
260260
TI(string="match"),
261261
TI(T.NUMBER | T.STRING | T.FSTRING_START | T.TSTRING_START)
262-
| TI(T.OP, string="(" | "*" | "[" | "{" | "~" | "...")
262+
| TI(T.OP, string="(" | "*" | "-" | "+" | "[" | "{" | "~" | "...")
263263
):
264264
return True
265265
case (

Lib/asyncio/coroutines.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
__all__ = ('iscoroutine',)
22

33
import collections.abc
4-
import inspect
54
import os
65
import sys
76
import types

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

0 commit comments

Comments
 (0)