Skip to content

Commit 66494ed

Browse files
Merge branch 'main' into pythongh-95855
2 parents 7fb142c + 33cb0b0 commit 66494ed

File tree

457 files changed

+10708
-5835
lines changed

Some content is hidden

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

457 files changed

+10708
-5835
lines changed

.coveragerc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ exclude_lines =
77
# Don't complain if non-runnable code isn't run:
88
if 0:
99
if __name__ == .__main__.:
10+
raise AssertionError\(
11+
12+
# Empty bodies in protocols or abstract methods
13+
^\s*def [a-zA-Z0-9_]+\(.*\)(\s*->.*)?:\s*\.\.\.(\s*#.*)?$
14+
^\s*\.\.\.(\s*#.*)?$
1015

1116
.*# pragma: no cover
1217
.*# pragma: no branch

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,11 @@ Doc/library/token-list.inc generated
7272
Include/internal/pycore_ast.h generated
7373
Include/internal/pycore_ast_state.h generated
7474
Include/internal/pycore_opcode.h generated
75+
Include/internal/pycore_opcode_metadata.h generated
7576
Include/internal/pycore_*_generated.h generated
7677
Include/opcode.h generated
7778
Include/token.h generated
79+
Lib/_opcode_metadata.py generated
7880
Lib/keyword.py generated
7981
Lib/test/levenshtein_examples.json generated
8082
Lib/test/test_stable_abi_ctypes.py generated

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ Python/traceback.c @iritkatriel
6969

7070
# Import (including importlib).
7171
**/*import* @brettcannon @ericsnowcurrently @ncoghlan @warsaw
72+
/Python/import.c @kumaraditya303
7273
**/*importlib/resources/* @jaraco @warsaw @FFY00
7374
**/importlib/metadata/* @jaraco @warsaw
7475

.github/ISSUE_TEMPLATE/bug.md

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,46 @@ labels: "type-bug"
55
---
66

77
<!--
8-
If you're new to Python and you're not sure whether what you're experiencing is a bug, the CPython issue tracker is not
9-
the right place to seek help. Consider the following options instead:
8+
New to Python? The issue tracker isn't the right place to get help.
9+
Consider instead:
1010
1111
- reading the Python tutorial: https://docs.python.org/3/tutorial/
12-
- posting in the "Users" category on discuss.python.org: https://discuss.python.org/c/users/7
13-
- emailing the Python-list mailing list: https://mail.python.org/mailman/listinfo/python-list
14-
- searching our issue tracker (https://github.com/python/cpython/issues) to see if
15-
your problem has already been reported
12+
- posting at https://discuss.python.org/c/users/7
13+
- emailing https://mail.python.org/mailman/listinfo/python-list
1614
-->
1715

1816
# Bug report
1917

20-
A clear and concise description of what the bug is.
21-
Include a minimal, reproducible example (https://stackoverflow.com/help/minimal-reproducible-example), if possible.
18+
## Checklist
19+
20+
<!-- Bugs in third-party projects (e.g. `requests`) do not belong in the CPython issue tracker -->
21+
22+
- [ ] I am confident this is a bug in CPython, not a bug in a third-party project
23+
- [ ] I have searched the CPython issue tracker, and am confident this bug has not been reported before
24+
25+
## A clear and concise description of the bug
26+
27+
<!--
28+
Include a minimal, reproducible example if possible.
29+
(https://stackoverflow.com/help/minimal-reproducible-example)
30+
31+
Put any code blocks inside triple backticks:
32+
33+
```py
34+
your code here
35+
```
36+
37+
-->
38+
39+
2240

2341
# Your environment
2442

25-
<!-- Include as many relevant details as possible about the environment you experienced the bug in -->
43+
<!-- Include all relevant details about the environment you experienced the bug in -->
2644

2745
- CPython versions tested on:
2846
- Operating system and architecture:
2947

3048
<!--
31-
You can freely edit this text. Remove any lines you believe are unnecessary.
49+
You can freely edit this form. Remove any lines you believe are unnecessary.
3250
-->

.github/ISSUE_TEMPLATE/crash.md

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,44 @@ labels: "type-crash"
55
---
66

77
<!--
8-
Use this template for hard crashes of the interpreter, segmentation faults, failed C-level assertions, and similar.
9-
Do not submit this form if you encounter an exception being unexpectedly raised from a Python function.
10-
Most of the time, these should be filed as bugs, rather than crashes.
8+
This form is for hard crashes of the Python interpreter, segmentation faults,
9+
failed C-level assertions, and similar.
10+
Exceptions unexpectedly raised from stdlib Python functions
11+
count as bugs rather than crashes.
1112
12-
The CPython interpreter is itself written in a different programming language, C.
13-
For CPython, a "crash" is when Python itself fails, leading to a traceback in the C stack.
13+
The CPython interpreter is written in a different programming language, C.
14+
A "CPython crash" is when Python itself fails, leading to a traceback in the C stack.
1415
-->
1516

1617
# Crash report
1718

18-
Tell us what happened, ideally including a minimal, reproducible example (https://stackoverflow.com/help/minimal-reproducible-example).
19+
<!--
20+
Tell us what happened. Ideally, include a minimal, reproducible example.
21+
(https://stackoverflow.com/help/minimal-reproducible-example)
22+
23+
Put any code blocks inside triple backticks:
24+
25+
```py
26+
your code here
27+
```
28+
29+
-->
30+
31+
1932

2033
# Error messages
2134

22-
Enter any relevant error message caused by the crash, including a core dump if there is one.
35+
<!-- Enter any error messages caused by the crash, including a core dump if there is one -->
36+
37+
2338

2439
# Your environment
2540

26-
<!-- Include as many relevant details as possible about the environment you experienced the bug in -->
41+
<!-- Include all relevant details about the environment you experienced the crash in -->
2742

2843
- CPython versions tested on:
2944
- Operating system and architecture:
3045

3146
<!--
32-
You can freely edit this text. Remove any lines you believe are unnecessary.
47+
You can freely edit this form. Remove any lines you believe are unnecessary.
3348
-->

.github/ISSUE_TEMPLATE/feature.md

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,47 @@ about: Submit a proposal for a new CPython feature or enhancement
44
labels: "type-feature"
55
---
66

7+
<!--
8+
Proposing a new feature for Python?
9+
You'll need to demonstrate widespread support for your idea among the community.
10+
11+
Major feature proposals should generally be discussed at
12+
https://discuss.python.org/c/ideas/6 before opening a GitHub issue.
13+
Wait until it's clear that most people support your idea
14+
before filling in this form.
15+
-->
16+
717
# Feature or enhancement
818

9-
(A clear and concise description of your proposal.)
19+
<!-- A clear and concise description of your proposal. -->
20+
21+
1022

1123
# Pitch
1224

13-
(Explain why this feature or enhancement should be implemented and how it would be used.
14-
Add examples, if applicable.)
25+
<!--
26+
Explain why this feature or enhancement should be implemented and how it would be used.
27+
Add examples, if applicable.
28+
29+
Put any code blocks inside triple backticks:
30+
31+
```py
32+
your code here
33+
```
34+
35+
-->
36+
37+
1538

1639
# Previous discussion
1740

1841
<!--
19-
New features to Python should first be discussed elsewhere before creating issues on GitHub,
20-
for example in the "ideas" category (https://discuss.python.org/c/ideas/6) of discuss.python.org,
21-
or the python-ideas mailing list (https://mail.python.org/mailman3/lists/python-ideas.python.org/).
22-
Use this space to post links to the places where you have already discussed this feature proposal:
42+
Use this space to post links to the places
43+
where you have already discussed your feature proposal:
2344
-->
2445

2546

47+
2648
<!--
27-
You can freely edit this text. Remove any lines you believe are unnecessary.
49+
You can freely edit this form. Remove any lines you believe are unnecessary.
2850
-->

Doc/c-api/allocation.rst

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,31 +27,34 @@ Allocating Objects on the Heap
2727
length information for a variable-size object.
2828
2929
30-
.. c:function:: TYPE* PyObject_New(TYPE, PyTypeObject *type)
30+
.. c:macro:: PyObject_New(TYPE, typeobj)
3131
3232
Allocate a new Python object using the C structure type *TYPE* and the
33-
Python type object *type*. Fields not defined by the Python object header
33+
Python type object *typeobj* (``PyTypeObject*``).
34+
Fields not defined by the Python object header
3435
are not initialized; the object's reference count will be one. The size of
3536
the memory allocation is determined from the :c:member:`~PyTypeObject.tp_basicsize` field of
3637
the type object.
3738
3839
39-
.. c:function:: TYPE* PyObject_NewVar(TYPE, PyTypeObject *type, Py_ssize_t size)
40+
.. c:macro:: PyObject_NewVar(TYPE, typeobj, size)
4041
4142
Allocate a new Python object using the C structure type *TYPE* and the
42-
Python type object *type*. Fields not defined by the Python object header
43+
Python type object *typeobj* (``PyTypeObject*``).
44+
Fields not defined by the Python object header
4345
are not initialized. The allocated memory allows for the *TYPE* structure
44-
plus *size* fields of the size given by the :c:member:`~PyTypeObject.tp_itemsize` field of
45-
*type*. This is useful for implementing objects like tuples, which are
46+
plus *size* (``Py_ssize_t``) fields of the size
47+
given by the :c:member:`~PyTypeObject.tp_itemsize` field of
48+
*typeobj*. This is useful for implementing objects like tuples, which are
4649
able to determine their size at construction time. Embedding the array of
4750
fields into the same allocation decreases the number of allocations,
4851
improving the memory management efficiency.
4952
5053
5154
.. c:function:: void PyObject_Del(void *op)
5255
53-
Releases memory allocated to an object using :c:func:`PyObject_New` or
54-
:c:func:`PyObject_NewVar`. This is normally called from the
56+
Releases memory allocated to an object using :c:macro:`PyObject_New` or
57+
:c:macro:`PyObject_NewVar`. This is normally called from the
5558
:c:member:`~PyTypeObject.tp_dealloc` handler specified in the object's type. The fields of
5659
the object should not be accessed after this call as the memory is no
5760
longer a valid Python object.

Doc/c-api/apiabiversion.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ See :ref:`stable` for a discussion of API and ABI stability across versions.
6060

6161
Use this for numeric comparisons, e.g. ``#if PY_VERSION_HEX >= ...``.
6262

63-
This version is also available via the symbol :data:`Py_Version`.
63+
This version is also available via the symbol :c:var:`Py_Version`.
6464

6565
.. c:var:: const unsigned long Py_Version
6666

Doc/c-api/arg.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ API Functions
477477
will be set if there was a failure.
478478
479479
This is an example of the use of this function, taken from the sources for the
480-
:mod:`_weakref` helper module for weak references::
480+
:mod:`!_weakref` helper module for weak references::
481481
482482
static PyObject *
483483
weakref_ref(PyObject *self, PyObject *args)

Doc/c-api/bool.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ creation and deletion functions don't apply to booleans. The following macros
1111
are available, however.
1212

1313

14+
.. c:var:: PyTypeObject PyBool_Type
15+
16+
This instance of :c:type:`PyTypeObject` represents the Python boolean type; it
17+
is the same object as :class:`bool` in the Python layer.
18+
19+
1420
.. c:function:: int PyBool_Check(PyObject *o)
1521
1622
Return true if *o* is of type :c:data:`PyBool_Type`. This function always

Doc/c-api/buffer.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ the elements exposed by an :class:`array.array` can be multi-byte values.
4444

4545
An example consumer of the buffer interface is the :meth:`~io.BufferedIOBase.write`
4646
method of file objects: any object that can export a series of bytes through
47-
the buffer interface can be written to a file. While :meth:`write` only
47+
the buffer interface can be written to a file. While :meth:`!write` only
4848
needs read-only access to the internal contents of the object passed to it,
4949
other methods such as :meth:`~io.BufferedIOBase.readinto` need write access
5050
to the contents of their argument. The buffer interface allows objects to

Doc/c-api/bytes.rst

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64,39 +64,39 @@ called with a non-bytes parameter.
6464
+-------------------+---------------+--------------------------------+
6565
| Format Characters | Type | Comment |
6666
+===================+===============+================================+
67-
| :attr:`%%` | *n/a* | The literal % character. |
67+
| ``%%`` | *n/a* | The literal % character. |
6868
+-------------------+---------------+--------------------------------+
69-
| :attr:`%c` | int | A single byte, |
69+
| ``%c`` | int | A single byte, |
7070
| | | represented as a C int. |
7171
+-------------------+---------------+--------------------------------+
72-
| :attr:`%d` | int | Equivalent to |
72+
| ``%d`` | int | Equivalent to |
7373
| | | ``printf("%d")``. [1]_ |
7474
+-------------------+---------------+--------------------------------+
75-
| :attr:`%u` | unsigned int | Equivalent to |
75+
| ``%u`` | unsigned int | Equivalent to |
7676
| | | ``printf("%u")``. [1]_ |
7777
+-------------------+---------------+--------------------------------+
78-
| :attr:`%ld` | long | Equivalent to |
78+
| ``%ld`` | long | Equivalent to |
7979
| | | ``printf("%ld")``. [1]_ |
8080
+-------------------+---------------+--------------------------------+
81-
| :attr:`%lu` | unsigned long | Equivalent to |
81+
| ``%lu`` | unsigned long | Equivalent to |
8282
| | | ``printf("%lu")``. [1]_ |
8383
+-------------------+---------------+--------------------------------+
84-
| :attr:`%zd` | :c:type:`\ | Equivalent to |
84+
| ``%zd`` | :c:type:`\ | Equivalent to |
8585
| | Py_ssize_t` | ``printf("%zd")``. [1]_ |
8686
+-------------------+---------------+--------------------------------+
87-
| :attr:`%zu` | size_t | Equivalent to |
87+
| ``%zu`` | size_t | Equivalent to |
8888
| | | ``printf("%zu")``. [1]_ |
8989
+-------------------+---------------+--------------------------------+
90-
| :attr:`%i` | int | Equivalent to |
90+
| ``%i`` | int | Equivalent to |
9191
| | | ``printf("%i")``. [1]_ |
9292
+-------------------+---------------+--------------------------------+
93-
| :attr:`%x` | int | Equivalent to |
93+
| ``%x`` | int | Equivalent to |
9494
| | | ``printf("%x")``. [1]_ |
9595
+-------------------+---------------+--------------------------------+
96-
| :attr:`%s` | const char\* | A null-terminated C character |
96+
| ``%s`` | const char\* | A null-terminated C character |
9797
| | | array. |
9898
+-------------------+---------------+--------------------------------+
99-
| :attr:`%p` | const void\* | The hex representation of a C |
99+
| ``%p`` | const void\* | The hex representation of a C |
100100
| | | pointer. Mostly equivalent to |
101101
| | | ``printf("%p")`` except that |
102102
| | | it is guaranteed to start with |

Doc/c-api/capsule.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ Refer to :ref:`using-capsules` for more information on using these objects.
6464
6565
The *name* parameter must compare exactly to the name stored in the capsule.
6666
If the name stored in the capsule is ``NULL``, the *name* passed in must also
67-
be ``NULL``. Python uses the C function :c:func:`strcmp` to compare capsule
67+
be ``NULL``. Python uses the C function :c:func:`!strcmp` to compare capsule
6868
names.
6969
7070
@@ -121,7 +121,7 @@ Refer to :ref:`using-capsules` for more information on using these objects.
121121
compared.)
122122
123123
In other words, if :c:func:`PyCapsule_IsValid` returns a true value, calls to
124-
any of the accessors (any function starting with :c:func:`PyCapsule_Get`) are
124+
any of the accessors (any function starting with ``PyCapsule_Get``) are
125125
guaranteed to succeed.
126126
127127
Return a nonzero value if the object is valid and matches the name passed in.

Doc/c-api/cell.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Cell objects are not likely to be useful elsewhere.
2525
The type object corresponding to cell objects.
2626

2727

28-
.. c:function:: int PyCell_Check(ob)
28+
.. c:function:: int PyCell_Check(PyObject *ob)
2929
3030
Return true if *ob* is a cell object; *ob* must not be ``NULL``. This
3131
function always succeeds.

0 commit comments

Comments
 (0)