Skip to content

Commit cef6950

Browse files
committed
Merge remote-tracking branch 'upstream/main' into default-ssl-verify-flags
Signed-off-by: William Woodruff <[email protected]>
2 parents 1a3e037 + ffed8d9 commit cef6950

File tree

549 files changed

+22593
-8932
lines changed

Some content is hidden

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

549 files changed

+22593
-8932
lines changed

.gitattributes

+2-1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ Include/internal/pycore_opcode.h generated
7777
Include/internal/pycore_opcode_metadata.h generated
7878
Include/internal/pycore_*_generated.h generated
7979
Include/internal/pycore_uop_ids.h generated
80+
Include/internal/pycore_uop_metadata.h generated
8081
Include/opcode.h generated
8182
Include/opcode_ids.h generated
8283
Include/token.h generated
@@ -96,7 +97,7 @@ Programs/test_frozenmain.h generated
9697
Python/Python-ast.c generated
9798
Python/executor_cases.c.h generated
9899
Python/generated_cases.c.h generated
99-
Python/tier2_redundancy_eliminator_bytecodes.c.h generated
100+
Python/optimizer_cases.c.h generated
100101
Python/opcode_targets.h generated
101102
Python/stdlib_module_names.h generated
102103
Tools/peg_generator/pegen/grammar_parser.py generated

.github/CODEOWNERS

+6-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Python/ast_opt.c @isidentical
3838
Python/bytecodes.c @markshannon @gvanrossum
3939
Python/optimizer*.c @markshannon @gvanrossum
4040
Python/optimizer_analysis.c @Fidget-Spinner
41-
Python/tier2_redundancy_eliminator_bytecodes.c @Fidget-Spinner
41+
Python/optimizer_bytecodes.c @Fidget-Spinner
4242
Lib/test/test_patma.py @brandtbucher
4343
Lib/test/test_type_*.py @JelleZijlstra
4444
Lib/test/test_capi/test_misc.py @markshannon @gvanrossum
@@ -247,5 +247,10 @@ Lib/test/test_interpreters/ @ericsnowcurrently
247247
/Tools/wasm/ @brettcannon
248248

249249
# SBOM
250+
/Misc/externals.spdx.json @sethmlarson
250251
/Misc/sbom.spdx.json @sethmlarson
251252
/Tools/build/generate_sbom.py @sethmlarson
253+
254+
# Config Parser
255+
Lib/configparser.py @jaraco
256+
Lib/test/test_configparser.py @jaraco

.github/workflows/build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ jobs:
162162
- name: Build CPython
163163
run: |
164164
make -j4 regen-all
165-
make regen-stdlib-module-names
165+
make regen-stdlib-module-names regen-sbom
166166
- name: Check for changes
167167
run: |
168168
git add -u

.github/workflows/jit.yml

+19-7
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ on:
55
- '**jit**'
66
- 'Python/bytecodes.c'
77
- 'Python/optimizer*.c'
8-
- 'Python/tier2_redundancy_eliminator_bytecodes.c'
8+
- 'Python/optimizer_bytecodes.c'
99
push:
1010
paths:
1111
- '**jit**'
1212
- 'Python/bytecodes.c'
1313
- 'Python/optimizer*.c'
14-
- 'Python/tier2_redundancy_eliminator_bytecodes.c'
14+
- 'Python/optimizer_bytecodes.c'
1515
workflow_dispatch:
1616

1717
concurrency:
@@ -29,6 +29,7 @@ jobs:
2929
target:
3030
- i686-pc-windows-msvc/msvc
3131
- x86_64-pc-windows-msvc/msvc
32+
- aarch64-pc-windows-msvc/msvc
3233
- x86_64-apple-darwin/clang
3334
- aarch64-apple-darwin/clang
3435
- x86_64-unknown-linux-gnu/gcc
@@ -49,6 +50,10 @@ jobs:
4950
architecture: x64
5051
runner: windows-latest
5152
compiler: msvc
53+
- target: aarch64-pc-windows-msvc/msvc
54+
architecture: ARM64
55+
runner: windows-latest
56+
compiler: msvc
5257
- target: x86_64-apple-darwin/clang
5358
architecture: x86_64
5459
runner: macos-13
@@ -70,13 +75,13 @@ jobs:
7075
runner: ubuntu-latest
7176
compiler: gcc
7277
# These fail because of emulation, not because of the JIT:
73-
exclude: test_unix_events test_init test_process_pool test_shutdown test_multiprocessing_fork test_cmd_line test_faulthandler test_os test_perf_profiler test_posix test_signal test_socket test_subprocess test_threading test_venv
78+
exclude: test_unix_events test_init test_process_pool test_shutdown test_multiprocessing_fork test_cmd_line test_faulthandler test_os test_perf_profiler test_posix test_signal test_socket test_subprocess test_threading test_venv test_external_inspection
7479
- target: aarch64-unknown-linux-gnu/clang
7580
architecture: aarch64
7681
runner: ubuntu-latest
7782
compiler: clang
7883
# These fail because of emulation, not because of the JIT:
79-
exclude: test_unix_events test_init test_process_pool test_shutdown test_multiprocessing_fork test_cmd_line test_faulthandler test_os test_perf_profiler test_posix test_signal test_socket test_subprocess test_threading test_venv
84+
exclude: test_unix_events test_init test_process_pool test_shutdown test_multiprocessing_fork test_cmd_line test_faulthandler test_os test_perf_profiler test_posix test_signal test_socket test_subprocess test_threading test_venv test_external_inspection
8085
env:
8186
CC: ${{ matrix.compiler }}
8287
steps:
@@ -85,14 +90,21 @@ jobs:
8590
with:
8691
python-version: '3.11'
8792

88-
- name: Windows
89-
if: runner.os == 'Windows'
93+
- name: Native Windows
94+
if: runner.os == 'Windows' && matrix.architecture != 'ARM64'
9095
run: |
9196
choco install llvm --allow-downgrade --no-progress --version ${{ matrix.llvm }}
9297
./PCbuild/build.bat --experimental-jit ${{ matrix.debug && '-d' || '--pgo' }} -p ${{ matrix.architecture }}
9398
./PCbuild/rt.bat ${{ matrix.debug && '-d' }} -p ${{ matrix.architecture }} -q --exclude ${{ matrix.exclude }} --multiprocess 0 --timeout 3600 --verbose2 --verbose3
9499
95-
- name: macOS
100+
# No PGO or tests (yet):
101+
- name: Emulated Windows
102+
if: runner.os == 'Windows' && matrix.architecture == 'ARM64'
103+
run: |
104+
choco install llvm --allow-downgrade --no-progress --version ${{ matrix.llvm }}
105+
./PCbuild/build.bat --experimental-jit ${{ matrix.debug && '-d' || '' }} -p ${{ matrix.architecture }}
106+
107+
- name: Native macOS
96108
if: runner.os == 'macOS'
97109
run: |
98110
brew install llvm@${{ matrix.llvm }}

.github/workflows/reusable-macos.yml

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ jobs:
1717
HOMEBREW_NO_ANALYTICS: 1
1818
HOMEBREW_NO_AUTO_UPDATE: 1
1919
HOMEBREW_NO_INSTALL_CLEANUP: 1
20+
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
2021
PYTHONSTRICTEXTENSIONBUILD: 1
2122
strategy:
2223
fail-fast: false

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ Lib/test/data/*
6969
/_bootstrap_python
7070
/Makefile
7171
/Makefile.pre
72+
iOS/Resources/Info.plist
7273
Mac/Makefile
7374
Mac/PythonLauncher/Info.plist
7475
Mac/PythonLauncher/Makefile

Doc/c-api/code.rst

+6-2
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,13 @@ bound into a function.
3030
Return true if *co* is a :ref:`code object <code-objects>`.
3131
This function always succeeds.
3232
33-
.. c:function:: int PyCode_GetNumFree(PyCodeObject *co)
33+
.. c:function:: Py_ssize_t PyCode_GetNumFree(PyCodeObject *co)
3434
35-
Return the number of free variables in *co*.
35+
Return the number of free variables in a code object.
36+
37+
.. c:function:: int PyCode_GetFirstFree(PyCodeObject *co)
38+
39+
Return the position of the first free variable in a code object.
3640
3741
.. 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, PyObject *qualname, int firstlineno, PyObject *linetable, PyObject *exceptiontable)
3842

Doc/c-api/exceptions.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ Printing and clearing
105105
parameters help format the warning message; they have the same meaning and
106106
values as in :c:func:`PyUnicode_FromFormat`.
107107
``PyErr_WriteUnraisable(obj)`` is roughtly equivalent to
108-
``PyErr_FormatUnraisable("Exception ignored in: %R, obj)``.
108+
``PyErr_FormatUnraisable("Exception ignored in: %R", obj)``.
109109
If *format* is ``NULL``, only the traceback is printed.
110110
111111
.. versionadded:: 3.13

Doc/c-api/long.rst

+57-17
Original file line numberDiff line numberDiff line change
@@ -358,46 +358,86 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
358358
359359
Copy the Python integer value to a native *buffer* of size *n_bytes*::
360360
361-
int value;
362-
Py_ssize_t bytes = PyLong_AsNativeBytes(v, &value, sizeof(value), -1);
361+
int32_t value;
362+
Py_ssize_t bytes = PyLong_AsNativeBits(pylong, &value, sizeof(value), -1);
363363
if (bytes < 0) {
364-
// Error occurred
364+
// A Python exception was set with the reason.
365365
return NULL;
366366
}
367367
else if (bytes <= (Py_ssize_t)sizeof(value)) {
368368
// Success!
369369
}
370370
else {
371-
// Overflow occurred, but 'value' contains truncated value
371+
// Overflow occurred, but 'value' contains the truncated
372+
// lowest bits of pylong.
372373
}
373374
375+
The above example may look *similar* to
376+
:c:func:`PyLong_As* <PyLong_AsSize_t>`
377+
but instead fills in a specific caller defined type and never raises an
378+
error about of the :class:`int` *pylong*'s value regardless of *n_bytes*
379+
or the returned byte count.
380+
381+
To get at the entire potentially big Python value, this can be used to
382+
reserve enough space and copy it::
383+
384+
// Ask how much space we need.
385+
Py_ssize_t expected = PyLong_AsNativeBits(pylong, NULL, 0, -1);
386+
if (expected < 0) {
387+
// A Python exception was set with the reason.
388+
return NULL;
389+
}
390+
assert(expected != 0); // Impossible per the API definition.
391+
uint8_t *bignum = malloc(expected);
392+
if (!bignum) {
393+
PyErr_SetString(PyExc_MemoryError, "bignum malloc failed.");
394+
return NULL;
395+
}
396+
// Safely get the entire value.
397+
Py_ssize_t bytes = PyLong_AsNativeBits(pylong, bignum, expected, -1);
398+
if (bytes < 0) { // Exception set.
399+
free(bignum);
400+
return NULL;
401+
}
402+
else if (bytes > expected) { // Be safe, should not be possible.
403+
PyErr_SetString(PyExc_RuntimeError,
404+
"Unexpected bignum truncation after a size check.");
405+
free(bignum);
406+
return NULL;
407+
}
408+
// The expected success given the above pre-check.
409+
// ... use bignum ...
410+
free(bignum);
411+
374412
*endianness* may be passed ``-1`` for the native endian that CPython was
375413
compiled with, or ``0`` for big endian and ``1`` for little.
376414
377-
Return ``-1`` with an exception raised if *pylong* cannot be interpreted as
415+
Returns ``-1`` with an exception raised if *pylong* cannot be interpreted as
378416
an integer. Otherwise, return the size of the buffer required to store the
379417
value. If this is equal to or less than *n_bytes*, the entire value was
380-
copied.
418+
copied. ``0`` will never be returned.
381419
382-
Unless an exception is raised, all *n_bytes* of the buffer will be written
383-
with as much of the value as can fit. This allows the caller to ignore all
384-
non-negative results if the intent is to match the typical behavior of a
385-
C-style downcast. No exception is set for this case.
420+
Unless an exception is raised, all *n_bytes* of the buffer will always be
421+
written. In the case of truncation, as many of the lowest bits of the value
422+
as could fit are written. This allows the caller to ignore all non-negative
423+
results if the intent is to match the typical behavior of a C-style
424+
downcast. No exception is set on truncation.
386425
387-
Values are always copied as two's-complement, and sufficient buffer will be
426+
Values are always copied as two's-complement and sufficient buffer will be
388427
requested to include a sign bit. For example, this may cause an value that
389428
fits into 8 bytes when treated as unsigned to request 9 bytes, even though
390429
all eight bytes were copied into the buffer. What has been omitted is the
391-
zero sign bit, which is redundant when the intention is to treat the value as
392-
unsigned.
430+
zero sign bit -- redundant if the caller's intention is to treat the value
431+
as unsigned.
393432
394-
Passing zero to *n_bytes* will return the requested buffer size.
433+
Passing zero to *n_bytes* will return the size of a buffer that would
434+
be large enough to hold the value. This may be larger than technically
435+
necessary, but not unreasonably so.
395436
396437
.. note::
397438
398-
When the value does not fit in the provided buffer, the requested size
399-
returned from the function may be larger than necessary. Passing 0 to this
400-
function is not an accurate way to determine the bit length of a value.
439+
Passing *n_bytes=0* to this function is not an accurate way to determine
440+
the bit length of a value.
401441
402442
.. versionadded:: 3.13
403443

Doc/conf.py

+3
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,13 @@
101101
('c:func', 'dlopen'),
102102
('c:func', 'exec'),
103103
('c:func', 'fcntl'),
104+
('c:func', 'flock'),
104105
('c:func', 'fork'),
105106
('c:func', 'free'),
106107
('c:func', 'gettimeofday'),
107108
('c:func', 'gmtime'),
108109
('c:func', 'grantpt'),
110+
('c:func', 'ioctl'),
109111
('c:func', 'localeconv'),
110112
('c:func', 'localtime'),
111113
('c:func', 'main'),
@@ -275,6 +277,7 @@
275277
('py:attr', '__annotations__'),
276278
('py:meth', '__missing__'),
277279
('py:attr', '__wrapped__'),
280+
('py:attr', 'decimal.Context.clamp'),
278281
('py:meth', 'index'), # list.index, tuple.index, etc.
279282
]
280283

Doc/faq/general.rst

+5-3
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,6 @@ Python versions are numbered "A.B.C" or "A.B":
133133
changes.
134134
* *C* is the micro version number -- it is incremented for each bugfix release.
135135

136-
See :pep:`6` for more information about bugfix releases.
137-
138136
Not all releases are bugfix releases. In the run-up to a new feature release, a
139137
series of development releases are made, denoted as alpha, beta, or release
140138
candidate. Alphas are early releases in which interfaces aren't yet finalized;
@@ -157,7 +155,11 @@ unreleased versions, built directly from the CPython development repository. In
157155
practice, after a final minor release is made, the version is incremented to the
158156
next minor version, which becomes the "a0" version, e.g. "2.4a0".
159157

160-
See also the documentation for :data:`sys.version`, :data:`sys.hexversion`, and
158+
See the `Developer's Guide
159+
<https://devguide.python.org/developer-workflow/development-cycle/>`__
160+
for more information about the development cycle, and
161+
:pep:`387` to learn more about Python's backward compatibility policy. See also
162+
the documentation for :data:`sys.version`, :data:`sys.hexversion`, and
161163
:data:`sys.version_info`.
162164

163165

0 commit comments

Comments
 (0)