Skip to content

Commit 22f1cbf

Browse files
authored
Merge branch 'main' into json-loads-opt
2 parents 57b4dc0 + 5ea1e90 commit 22f1cbf

76 files changed

Lines changed: 499 additions & 221 deletions

File tree

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/curses.ascii.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ C library:
130130

131131
.. function:: isgraph(c)
132132

133-
Checks for ASCII any printable character except space.
133+
Checks for any ASCII printable character except space.
134134

135135

136136
.. function:: islower(c)
@@ -145,7 +145,7 @@ C library:
145145

146146
.. function:: ispunct(c)
147147

148-
Checks for any printable ASCII character which is not a space or an alphanumeric
148+
Checks for any ASCII printable character which is not a space or an alphanumeric
149149
character.
150150

151151

Doc/library/enum.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ Data types
629629
>>> white in purple
630630
False
631631

632-
.. method:: __iter__(self):
632+
.. method:: __iter__(self)
633633

634634
Returns all contained non-alias members::
635635

@@ -640,7 +640,7 @@ Data types
640640

641641
.. versionadded:: 3.11
642642

643-
.. method:: __len__(self):
643+
.. method:: __len__(self)
644644

645645
Returns number of members in flag::
646646

@@ -651,7 +651,7 @@ Data types
651651

652652
.. versionadded:: 3.11
653653

654-
.. method:: __bool__(self):
654+
.. method:: __bool__(self)
655655

656656
Returns *True* if any members in flag, *False* otherwise::
657657

@@ -688,7 +688,7 @@ Data types
688688
>>> purple ^ Color.GREEN
689689
<Color.RED|GREEN|BLUE: 7>
690690

691-
.. method:: __invert__(self):
691+
.. method:: __invert__(self)
692692

693693
Returns all the flags in *type(self)* that are not in *self*::
694694

Doc/library/functions.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ are always available. They are listed here in alphabetical order.
485485
:noindex:
486486
487487
Create a new dictionary. The :class:`dict` object is the dictionary class.
488-
See :class:`dict` and :ref:`typesmapping` for documentation about this class.
488+
See also :ref:`typesmapping` for documentation about this class.
489489

490490
For other containers see the built-in :class:`frozendict`, :class:`list`,
491491
:class:`set`, and :class:`tuple` classes, as well as the :mod:`collections` module.
@@ -873,7 +873,7 @@ are always available. They are listed here in alphabetical order.
873873
:noindex:
874874
875875
Create a new frozen dictionary. The :class:`frozendict` object is a built-in class.
876-
See :class:`frozendict` and :ref:`typesmapping` for documentation about this class.
876+
See also :ref:`typesmapping` for documentation about this class.
877877

878878
For other containers see the built-in :class:`dict`, :class:`list`, :class:`set`,
879879
and :class:`tuple` classes, as well as the :mod:`collections` module.
@@ -886,7 +886,7 @@ are always available. They are listed here in alphabetical order.
886886
:noindex:
887887

888888
Return a new :class:`frozenset` object, optionally with elements taken from
889-
*iterable*. ``frozenset`` is a built-in class. See :class:`frozenset` and
889+
*iterable*. :class:`frozenset` is a built-in class. See also
890890
:ref:`types-set` for documentation about this class.
891891

892892
For other containers see the built-in :class:`set`, :class:`list`,
@@ -1814,7 +1814,7 @@ are always available. They are listed here in alphabetical order.
18141814
:noindex:
18151815

18161816
Return a new :class:`set` object, optionally with elements taken from
1817-
*iterable*. ``set`` is a built-in class. See :class:`set` and
1817+
*iterable*. :class:`set` is a built-in class. See also
18181818
:ref:`types-set` for documentation about this class.
18191819

18201820
For other containers see the built-in :class:`frozenset`, :class:`list`,

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/unittest.mock.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2539,7 +2539,7 @@ Alternatively you can just use ``vars(my_mock)`` (instance members) and
25392539
mock_open
25402540
~~~~~~~~~
25412541

2542-
.. function:: mock_open(mock=None, read_data=None)
2542+
.. function:: mock_open(mock=None, read_data='')
25432543

25442544
A helper function to create a mock to replace the use of :func:`open`. It works
25452545
for :func:`open` called directly or used as a context manager.

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 (

0 commit comments

Comments
 (0)