Skip to content

Commit 652dd19

Browse files
committed
Merge remote-tracking branch 'cpython/main' into pythongh-99726-2
2 parents 0314273 + 4e7c0cb commit 652dd19

Some content is hidden

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

71 files changed

+1505
-1116
lines changed

.github/workflows/new-bugs-announce-notifier.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ jobs:
1919
- name: Send notification
2020
uses: actions/github-script@v6
2121
env:
22-
MAILGUN_API_KEY: ${{ secrets.PSF_MAILGUN_KEY }}
22+
MAILGUN_API_KEY: ${{ secrets.MAILGUN_PYTHON_ORG_MAILGUN_KEY }}
2323
with:
2424
script: |
2525
const Mailgun = require("mailgun.js");
2626
const formData = require('form-data');
2727
const mailgun = new Mailgun(formData);
28-
const DOMAIN = "mg.python.org";
28+
const DOMAIN = "mailgun.python.org";
2929
const mg = mailgun.client({username: 'api', key: process.env.MAILGUN_API_KEY});
3030
github.rest.issues.get({
3131
issue_number: context.issue.number,
@@ -44,7 +44,7 @@ jobs:
4444
};
4545
4646
const data = {
47-
from: "CPython Issues <github@mg.python.org>",
47+
from: "CPython Issues <github@mailgun.python.org>",
4848
to: "new-bugs-announce@python.org",
4949
subject: `[Issue ${issue.data.number}] ${issue.data.title}`,
5050
template: "new-github-issue",

Doc/c-api/code.rst

Lines changed: 92 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,28 +33,47 @@ bound into a function.
3333
3434
Return the number of free variables in *co*.
3535
36-
.. c:function:: PyCodeObject* PyCode_New(int argcount, int kwonlyargcount, int nlocals, int stacksize, int flags, PyObject *code, PyObject *consts, PyObject *names, PyObject *varnames, PyObject *freevars, PyObject *cellvars, PyObject *filename, PyObject *name, int firstlineno, PyObject *linetable, PyObject *exceptiontable)
36+
.. c:function:: PyCodeObject* PyUnstable_Code_New(int argcount, int kwonlyargcount, int nlocals, int stacksize, int flags, PyObject *code, PyObject *consts, PyObject *names, PyObject *varnames, PyObject *freevars, PyObject *cellvars, PyObject *filename, PyObject *name, int firstlineno, PyObject *linetable, PyObject *exceptiontable)
3737
3838
Return a new code object. If you need a dummy code object to create a frame,
39-
use :c:func:`PyCode_NewEmpty` instead. Calling :c:func:`PyCode_New` directly
40-
will bind you to a precise Python version since the definition of the bytecode
41-
changes often. The many arguments of this function are inter-dependent in complex
39+
use :c:func:`PyCode_NewEmpty` instead.
40+
41+
Since the definition of the bytecode changes often, calling
42+
:c:func:`PyCode_New` directly can bind you to a precise Python version.
43+
44+
The many arguments of this function are inter-dependent in complex
4245
ways, meaning that subtle changes to values are likely to result in incorrect
4346
execution or VM crashes. Use this function only with extreme care.
4447
4548
.. versionchanged:: 3.11
4649
Added ``exceptiontable`` parameter.
4750
48-
.. c:function:: PyCodeObject* PyCode_NewWithPosOnlyArgs(int argcount, int posonlyargcount, int kwonlyargcount, int nlocals, int stacksize, int flags, PyObject *code, PyObject *consts, PyObject *names, PyObject *varnames, PyObject *freevars, PyObject *cellvars, PyObject *filename, PyObject *name, int firstlineno, PyObject *linetable, PyObject *exceptiontable)
51+
.. index:: single: PyCode_New
52+
53+
.. versionchanged:: 3.12
54+
55+
Renamed from ``PyCode_New`` as part of :ref:`unstable-c-api`.
56+
The old name is deprecated, but will remain available until the
57+
signature changes again.
58+
59+
.. c:function:: PyCodeObject* PyUnstable_Code_NewWithPosOnlyArgs(int argcount, int posonlyargcount, int kwonlyargcount, int nlocals, int stacksize, int flags, PyObject *code, PyObject *consts, PyObject *names, PyObject *varnames, PyObject *freevars, PyObject *cellvars, PyObject *filename, PyObject *name, int firstlineno, PyObject *linetable, PyObject *exceptiontable)
4960
5061
Similar to :c:func:`PyCode_New`, but with an extra "posonlyargcount" for positional-only arguments.
5162
The same caveats that apply to ``PyCode_New`` also apply to this function.
5263
53-
.. versionadded:: 3.8
64+
.. index:: single: PyCode_NewWithPosOnlyArgs
65+
66+
.. versionadded:: 3.8 as ``PyCode_NewWithPosOnlyArgs``
5467
5568
.. versionchanged:: 3.11
5669
Added ``exceptiontable`` parameter.
5770
71+
.. versionchanged:: 3.12
72+
73+
Renamed to ``PyUnstable_Code_NewWithPosOnlyArgs``.
74+
The old name is deprecated, but will remain available until the
75+
signature changes again.
76+
5877
.. c:function:: PyCodeObject* PyCode_NewEmpty(const char *filename, const char *funcname, int firstlineno)
5978
6079
Return a new empty code object with the specified filename,
@@ -165,3 +184,70 @@ bound into a function.
165184
:c:func:`PyErr_WriteUnraisable`. Otherwise it should return ``0``.
166185
167186
.. versionadded:: 3.12
187+
188+
189+
Extra information
190+
-----------------
191+
192+
To support low-level extensions to frame evaluation, such as external
193+
just-in-time compilers, it is possible to attach arbitrary extra data to
194+
code objects.
195+
196+
These functions are part of the unstable C API tier:
197+
this functionality is a CPython implementation detail, and the API
198+
may change without deprecation warnings.
199+
200+
.. c:function:: Py_ssize_t PyUnstable_Eval_RequestCodeExtraIndex(freefunc free)
201+
202+
Return a new an opaque index value used to adding data to code objects.
203+
204+
You generally call this function once (per interpreter) and use the result
205+
with ``PyCode_GetExtra`` and ``PyCode_SetExtra`` to manipulate
206+
data on individual code objects.
207+
208+
If *free* is not ``NULL``: when a code object is deallocated,
209+
*free* will be called on non-``NULL`` data stored under the new index.
210+
Use :c:func:`Py_DecRef` when storing :c:type:`PyObject`.
211+
212+
.. index:: single: _PyEval_RequestCodeExtraIndex
213+
214+
.. versionadded:: 3.6 as ``_PyEval_RequestCodeExtraIndex``
215+
216+
.. versionchanged:: 3.12
217+
218+
Renamed to ``PyUnstable_Eval_RequestCodeExtraIndex``.
219+
The old private name is deprecated, but will be available until the API
220+
changes.
221+
222+
.. c:function:: int PyUnstable_Code_GetExtra(PyObject *code, Py_ssize_t index, void **extra)
223+
224+
Set *extra* to the extra data stored under the given index.
225+
Return 0 on success. Set an exception and return -1 on failure.
226+
227+
If no data was set under the index, set *extra* to ``NULL`` and return
228+
0 without setting an exception.
229+
230+
.. index:: single: _PyCode_GetExtra
231+
232+
.. versionadded:: 3.6 as ``_PyCode_GetExtra``
233+
234+
.. versionchanged:: 3.12
235+
236+
Renamed to ``PyUnstable_Code_GetExtra``.
237+
The old private name is deprecated, but will be available until the API
238+
changes.
239+
240+
.. c:function:: int PyUnstable_Code_SetExtra(PyObject *code, Py_ssize_t index, void *extra)
241+
242+
Set the extra data stored under the given index to *extra*.
243+
Return 0 on success. Set an exception and return -1 on failure.
244+
245+
.. index:: single: _PyCode_SetExtra
246+
247+
.. versionadded:: 3.6 as ``_PyCode_SetExtra``
248+
249+
.. versionchanged:: 3.12
250+
251+
Renamed to ``PyUnstable_Code_SetExtra``.
252+
The old private name is deprecated, but will be available until the API
253+
changes.

Doc/c-api/stable.rst

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
C API Stability
77
***************
88

9-
Python's C API is covered by the Backwards Compatibility Policy, :pep:`387`.
10-
While the C API will change with every minor release (e.g. from 3.9 to 3.10),
11-
most changes will be source-compatible, typically by only adding new API.
9+
Unless documented otherwise, Python's C API is covered by the Backwards
10+
Compatibility Policy, :pep:`387`.
11+
Most changes to it are source-compatible (typically by only adding new API).
1212
Changing existing API or removing API is only done after a deprecation period
1313
or to fix serious issues.
1414

@@ -18,8 +18,38 @@ way; see :ref:`stable-abi-platform` below).
1818
So, code compiled for Python 3.10.0 will work on 3.10.8 and vice versa,
1919
but will need to be compiled separately for 3.9.x and 3.10.x.
2020

21+
There are two tiers of C API with different stability exepectations:
22+
23+
- *Unstable API*, may change in minor versions without a deprecation period.
24+
It is marked by the ``PyUnstable`` prefix in names.
25+
- *Limited API*, is compatible across several minor releases.
26+
When :c:macro:`Py_LIMITED_API` is defined, only this subset is exposed
27+
from ``Python.h``.
28+
29+
These are discussed in more detail below.
30+
2131
Names prefixed by an underscore, such as ``_Py_InternalState``,
2232
are private API that can change without notice even in patch releases.
33+
If you need to use this API, consider reaching out to
34+
`CPython developers <https://discuss.python.org/c/core-dev/c-api/30>`_
35+
to discuss adding public API for your use case.
36+
37+
.. _unstable-c-api:
38+
39+
Unstable C API
40+
==============
41+
42+
.. index:: single: PyUnstable
43+
44+
Any API named with the ``PyUnstable`` prefix exposes CPython implementation
45+
details, and may change in every minor release (e.g. from 3.9 to 3.10) without
46+
any deprecation warnings.
47+
However, it will not change in a bugfix release (e.g. from 3.10.0 to 3.10.1).
48+
49+
It is generally intended for specialized, low-level tools like debuggers.
50+
51+
Projects that use this API are expected to follow
52+
CPython development and spend extra effort adjusting to changes.
2353

2454

2555
Stable Application Binary Interface

Doc/conf.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@
268268
ogp_site_name = 'Python documentation'
269269
ogp_image = '_static/og-image.png'
270270
ogp_custom_meta_tags = [
271-
'<meta property="og:image:width" content="200">',
272-
'<meta property="og:image:height" content="200">',
273-
'<meta name="theme-color" content="#3776ab">',
271+
'<meta property="og:image:width" content="200" />',
272+
'<meta property="og:image:height" content="200" />',
273+
'<meta name="theme-color" content="#3776ab" />',
274274
]

Doc/library/itertools.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -886,9 +886,12 @@ which incur interpreter overhead.
886886
except AttributeError:
887887
# Slow path for general iterables
888888
it = islice(iterable, start, None)
889-
for i, element in enumerate(it, start):
890-
if element is value or element == value:
891-
yield i
889+
i = start - 1
890+
try:
891+
while True:
892+
yield (i := i + operator.indexOf(it, value) + 1)
893+
except ValueError:
894+
pass
892895
else:
893896
# Fast path for sequences
894897
i = start - 1

Doc/library/os.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,11 @@ process and user.
201201
``'surrogateescape'`` error handler. Use :data:`environb` if you would like
202202
to use a different encoding.
203203

204+
On Windows, the keys are converted to uppercase. This also applies when
205+
getting, setting, or deleting an item. For example,
206+
``environ['monty'] = 'python'`` maps the key ``'MONTY'`` to the value
207+
``'python'``.
208+
204209
.. note::
205210

206211
Calling :func:`putenv` directly does not change :data:`os.environ`, so it's better

Doc/library/sqlite3.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ including `cursors`_ and `transactions`_.
7272

7373
First, we need to create a new database and open
7474
a database connection to allow :mod:`!sqlite3` to work with it.
75-
Call :func:`sqlite3.connect` to to create a connection to
75+
Call :func:`sqlite3.connect` to create a connection to
7676
the database :file:`tutorial.db` in the current working directory,
7777
implicitly creating it if it does not exist:
7878

0 commit comments

Comments
 (0)