Skip to content

Commit f6c4024

Browse files
committed
Merge branch 'main' into test-cppext
2 parents 7c40f3c + 1724553 commit f6c4024

File tree

598 files changed

+23435
-12108
lines changed

Some content is hidden

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

598 files changed

+23435
-12108
lines changed

.devcontainer/Dockerfile

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
FROM docker.io/library/fedora:37
2+
3+
ENV CC=clang
4+
5+
ENV WASI_SDK_VERSION=19
6+
ENV WASI_SDK_PATH=/opt/wasi-sdk
7+
8+
ENV WASMTIME_HOME=/opt/wasmtime
9+
ENV WASMTIME_VERSION=7.0.0
10+
ENV WASMTIME_CPU_ARCH=x86_64
11+
12+
RUN dnf -y --nodocs install git clang xz python3-blurb dnf-plugins-core && \
13+
dnf -y --nodocs builddep python3 && \
14+
dnf -y clean all
15+
16+
RUN mkdir ${WASI_SDK_PATH} && \
17+
curl --location https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_SDK_VERSION}/wasi-sdk-${WASI_SDK_VERSION}.0-linux.tar.gz | \
18+
tar --strip-components 1 --directory ${WASI_SDK_PATH} --extract --gunzip
19+
20+
RUN mkdir --parents ${WASMTIME_HOME} && \
21+
curl --location "https://github.com/bytecodealliance/wasmtime/releases/download/v${WASMTIME_VERSION}/wasmtime-v${WASMTIME_VERSION}-${WASMTIME_CPU_ARCH}-linux.tar.xz" | \
22+
xz --decompress | \
23+
tar --strip-components 1 --directory ${WASMTIME_HOME} -x && \
24+
ln -s ${WASMTIME_HOME}/wasmtime /usr/local/bin

.devcontainer/devcontainer.json

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
{
2+
"build": {
3+
"dockerfile": "Dockerfile"
4+
},
5+
"onCreateCommand": [
6+
// Install common tooling.
7+
"dnf",
8+
"install",
9+
"-y",
10+
"which",
11+
"zsh",
12+
"fish"
13+
],
14+
"updateContentCommand": {
15+
// Using the shell for `nproc` usage.
16+
"python": "./configure --config-cache --with-pydebug && make -s -j `nproc`",
17+
"docs": [
18+
"make",
19+
"--directory",
20+
"Doc",
21+
"venv",
22+
"html"
23+
]
24+
},
25+
"customizations": {
26+
"vscode": {
27+
"extensions": [
28+
// Highlighting for Parser/Python.asdl.
29+
"brettcannon.zephyr-asdl",
30+
// Highlighting for configure.ac.
31+
"maelvalais.autoconf",
32+
// C auto-complete.
33+
"ms-vscode.cpptools",
34+
// To view built docs.
35+
"ms-vscode.live-server"
36+
// https://github.com/microsoft/vscode-python/issues/18073
37+
// "ms-python.python"
38+
],
39+
"settings": {
40+
"C_Cpp.default.compilerPath": "/usr/bin/clang",
41+
"C_Cpp.default.cStandard": "c11",
42+
"C_Cpp.default.defines": [
43+
"CONFIG_64",
44+
"Py_BUILD_CORE"
45+
],
46+
"C_Cpp.default.includePath": [
47+
"${workspaceFolder}/*",
48+
"${workspaceFolder}/Include/**"
49+
],
50+
// https://github.com/microsoft/vscode-cpptools/issues/10732
51+
"C_Cpp.errorSquiggles": "disabled",
52+
"editor.insertSpaces": true,
53+
"editor.rulers": [
54+
80
55+
],
56+
"editor.tabSize": 4,
57+
"editor.trimAutoWhitespace": true,
58+
"files.associations": {
59+
"*.h": "c"
60+
},
61+
"files.encoding": "utf8",
62+
"files.eol": "\n",
63+
"files.insertFinalNewline": true,
64+
"files.trimTrailingWhitespace": true,
65+
"python.analysis.diagnosticSeverityOverrides": {
66+
// Complains about shadowing the stdlib w/ the stdlib.
67+
"reportShadowedImports": "none",
68+
// Doesn't like _frozen_importlib.
69+
"reportMissingImports": "none"
70+
},
71+
"python.analysis.extraPaths": [
72+
"Lib"
73+
],
74+
"python.defaultInterpreterPath": "./python",
75+
"[restructuredtext]": {
76+
"editor.tabSize": 3
77+
}
78+
}
79+
}
80+
}
81+
}

.github/workflows/build.yml

+3
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ jobs:
111111
run: make smelly
112112
- name: Check limited ABI symbols
113113
run: make check-limited-abi
114+
- name: Check for unsupported C global variables
115+
if: github.event_name == 'pull_request' # $GITHUB_EVENT_NAME
116+
run: make check-c-globals
114117

115118
build_win32:
116119
name: 'Windows (x86)'

.github/workflows/doc.yml

+23
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,29 @@ jobs:
5353
- name: 'Build HTML documentation'
5454
run: make -C Doc/ SPHINXOPTS="-q" SPHINXERRORHANDLING="-W --keep-going" html
5555

56+
# Add pull request annotations for Sphinx nitpicks (missing references)
57+
- name: 'Get list of changed files'
58+
id: changed_files
59+
uses: Ana06/[email protected]
60+
with:
61+
filter: "Doc/**"
62+
- name: 'Build changed files in nit-picky mode'
63+
continue-on-error: true
64+
run: |
65+
# Mark files the pull request modified
66+
touch ${{ steps.changed_files.outputs.added_modified }}
67+
# Build docs with the '-n' (nit-picky) option; convert warnings to annotations
68+
make -C Doc/ PYTHON=../python SPHINXOPTS="-q -n --keep-going" html 2>&1 |
69+
python Doc/tools/warnings-to-gh-actions.py
70+
71+
# Ensure some files always pass Sphinx nit-picky mode (no missing references)
72+
- name: 'Build known-good files in nit-picky mode'
73+
run: |
74+
# Mark files that must pass nit-picky
75+
python Doc/tools/touch-clean-files.py
76+
# Build docs with the '-n' (nit-picky) option, convert warnings to errors (-W)
77+
make -C Doc/ PYTHON=../python SPHINXOPTS="-q -n -W --keep-going" html 2>&1
78+
5679
# Run "doctest" on HEAD as new syntax doesn't exist in the latest stable release
5780
doctest:
5881
name: 'Doctest'

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

+3-3
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
4949
subject: `[Issue ${issue.data.number}] ${issue.data.title}`,
5050
template: "new-github-issue",

Doc/bugs.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ Click on the "New issue" button in the top bar to report a new issue.
7070
The submission form has two fields, "Title" and "Comment".
7171

7272
For the "Title" field, enter a *very* short description of the problem;
73-
less than ten words is good.
73+
fewer than ten words is good.
7474

7575
In the "Comment" field, describe the problem in detail, including what you
7676
expected to happen and what did happen. Be sure to include whether any

Doc/c-api/buffer.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ Buffer-related functions
499499
This function fails if *len* != *src->len*.
500500
501501
502-
.. c:function:: int PyObject_CopyData(Py_buffer *dest, Py_buffer *src)
502+
.. c:function:: int PyObject_CopyData(PyObject *dest, PyObject *src)
503503
504504
Copy data from *src* to *dest* buffer. Can convert between C-style and
505505
or Fortran-style buffers.

Doc/c-api/code.rst

+106-9
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,
@@ -153,15 +172,93 @@ bound into a function.
153172
before the destruction of *co* takes place, so the prior state of *co*
154173
can be inspected.
155174
175+
If *event* is ``PY_CODE_EVENT_DESTROY``, taking a reference in the callback
176+
to the about-to-be-destroyed code object will resurrect it and prevent it
177+
from being freed at this time. When the resurrected object is destroyed
178+
later, any watcher callbacks active at that time will be called again.
179+
156180
Users of this API should not rely on internal runtime implementation
157181
details. Such details may include, but are not limited to, the exact
158182
order and timing of creation and destruction of code objects. While
159183
changes in these details may result in differences observable by watchers
160184
(including whether a callback is invoked or not), it does not change
161185
the semantics of the Python code being executed.
162186
163-
If the callback returns with an exception set, it must return ``-1``; this
164-
exception will be printed as an unraisable exception using
165-
:c:func:`PyErr_WriteUnraisable`. Otherwise it should return ``0``.
187+
If the callback sets an exception, it must return ``-1``; this exception will
188+
be printed as an unraisable exception using :c:func:`PyErr_WriteUnraisable`.
189+
Otherwise it should return ``0``.
190+
191+
There may already be a pending exception set on entry to the callback. In
192+
this case, the callback should return ``0`` with the same exception still
193+
set. This means the callback may not call any other API that can set an
194+
exception unless it saves and clears the exception state first, and restores
195+
it before returning.
166196
167197
.. versionadded:: 3.12
198+
199+
200+
Extra information
201+
-----------------
202+
203+
To support low-level extensions to frame evaluation, such as external
204+
just-in-time compilers, it is possible to attach arbitrary extra data to
205+
code objects.
206+
207+
These functions are part of the unstable C API tier:
208+
this functionality is a CPython implementation detail, and the API
209+
may change without deprecation warnings.
210+
211+
.. c:function:: Py_ssize_t PyUnstable_Eval_RequestCodeExtraIndex(freefunc free)
212+
213+
Return a new an opaque index value used to adding data to code objects.
214+
215+
You generally call this function once (per interpreter) and use the result
216+
with ``PyCode_GetExtra`` and ``PyCode_SetExtra`` to manipulate
217+
data on individual code objects.
218+
219+
If *free* is not ``NULL``: when a code object is deallocated,
220+
*free* will be called on non-``NULL`` data stored under the new index.
221+
Use :c:func:`Py_DecRef` when storing :c:type:`PyObject`.
222+
223+
.. index:: single: _PyEval_RequestCodeExtraIndex
224+
225+
.. versionadded:: 3.6 as ``_PyEval_RequestCodeExtraIndex``
226+
227+
.. versionchanged:: 3.12
228+
229+
Renamed to ``PyUnstable_Eval_RequestCodeExtraIndex``.
230+
The old private name is deprecated, but will be available until the API
231+
changes.
232+
233+
.. c:function:: int PyUnstable_Code_GetExtra(PyObject *code, Py_ssize_t index, void **extra)
234+
235+
Set *extra* to the extra data stored under the given index.
236+
Return 0 on success. Set an exception and return -1 on failure.
237+
238+
If no data was set under the index, set *extra* to ``NULL`` and return
239+
0 without setting an exception.
240+
241+
.. index:: single: _PyCode_GetExtra
242+
243+
.. versionadded:: 3.6 as ``_PyCode_GetExtra``
244+
245+
.. versionchanged:: 3.12
246+
247+
Renamed to ``PyUnstable_Code_GetExtra``.
248+
The old private name is deprecated, but will be available until the API
249+
changes.
250+
251+
.. c:function:: int PyUnstable_Code_SetExtra(PyObject *code, Py_ssize_t index, void *extra)
252+
253+
Set the extra data stored under the given index to *extra*.
254+
Return 0 on success. Set an exception and return -1 on failure.
255+
256+
.. index:: single: _PyCode_SetExtra
257+
258+
.. versionadded:: 3.6 as ``_PyCode_SetExtra``
259+
260+
.. versionchanged:: 3.12
261+
262+
Renamed to ``PyUnstable_Code_SetExtra``.
263+
The old private name is deprecated, but will be available until the API
264+
changes.

Doc/c-api/dict.rst

+17-4
Original file line numberDiff line numberDiff line change
@@ -298,13 +298,26 @@ Dictionary Objects
298298
dictionary.
299299
300300
The callback may inspect but must not modify *dict*; doing so could have
301-
unpredictable effects, including infinite recursion.
301+
unpredictable effects, including infinite recursion. Do not trigger Python
302+
code execution in the callback, as it could modify the dict as a side effect.
303+
304+
If *event* is ``PyDict_EVENT_DEALLOCATED``, taking a new reference in the
305+
callback to the about-to-be-destroyed dictionary will resurrect it and
306+
prevent it from being freed at this time. When the resurrected object is
307+
destroyed later, any watcher callbacks active at that time will be called
308+
again.
302309
303310
Callbacks occur before the notified modification to *dict* takes place, so
304311
the prior state of *dict* can be inspected.
305312
306-
If the callback returns with an exception set, it must return ``-1``; this
307-
exception will be printed as an unraisable exception using
308-
:c:func:`PyErr_WriteUnraisable`. Otherwise it should return ``0``.
313+
If the callback sets an exception, it must return ``-1``; this exception will
314+
be printed as an unraisable exception using :c:func:`PyErr_WriteUnraisable`.
315+
Otherwise it should return ``0``.
316+
317+
There may already be a pending exception set on entry to the callback. In
318+
this case, the callback should return ``0`` with the same exception still
319+
set. This means the callback may not call any other API that can set an
320+
exception unless it saves and clears the exception state first, and restores
321+
it before returning.
309322
310323
.. versionadded:: 3.12

Doc/c-api/exceptions.rst

+6
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,12 @@ Printing and clearing
8686
8787
An exception must be set when calling this function.
8888
89+
.. c:function:: void PyErr_DisplayException(PyObject *exc)
90+
91+
Print the standard traceback display of ``exc`` to ``sys.stderr``, including
92+
chained exceptions and notes.
93+
94+
.. versionadded:: 3.12
8995
9096
Raising exceptions
9197
==================

0 commit comments

Comments
 (0)