Skip to content

Commit a30b7e6

Browse files
committed
Merge branch 'main' into thread-local-interpreter-state
2 parents 193b646 + 98fac8b commit a30b7e6

File tree

361 files changed

+24106
-14597
lines changed

Some content is hidden

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

361 files changed

+24106
-14597
lines changed

.github/workflows/build.yml

+38-10
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,18 @@ jobs:
6464
- uses: actions/setup-python@v2
6565
- name: Install Dependencies
6666
run: sudo ./.github/workflows/posix-deps-apt.sh
67+
- name: Add ccache to PATH
68+
run: echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
69+
- name: Configure ccache action
70+
uses: hendrikmuhs/ccache-action@v1
71+
- name: Check Autoconf version 2.69 and aclocal 1.16.3
72+
run: |
73+
grep "Generated by GNU Autoconf 2.69" configure
74+
grep "aclocal 1.16.3" aclocal.m4
75+
grep -q "runstatedir" configure
76+
grep -q "PKG_PROG_PKG_CONFIG" aclocal.m4
77+
- name: Regenerate autoconf files
78+
run: docker run --rm -v $(pwd):/src quay.io/tiran/cpython_autoconf:269
6779
- name: Build CPython
6880
run: |
6981
# Build Python with the libpython dynamic library
@@ -75,26 +87,25 @@ jobs:
7587
git add -u
7688
changes=$(git status --porcelain)
7789
# Check for changes in regenerated files
78-
if ! test -z "$changes"
79-
then
80-
echo "Generated files not up to date. Perhaps you forgot to run make regen-all or build.bat --regen ;)"
90+
if test -n "$changes"; then
91+
echo "Generated files not up to date."
92+
echo "Perhaps you forgot to run make regen-all or build.bat --regen. ;)"
93+
echo "configure files must be regenerated with a specific, unpatched version of autoconf."
8194
echo "$changes"
8295
exit 1
8396
fi
8497
- name: Check exported libpython symbols
8598
run: make smelly
8699
- name: Check limited ABI symbols
87100
run: make check-limited-abi
88-
- name: Check Autoconf version 2.69
89-
run: |
90-
grep "Generated by GNU Autoconf 2.69" configure
91-
grep "PKG_PROG_PKG_CONFIG" aclocal.m4
92101

93102
build_win32:
94103
name: 'Windows (x86)'
95104
runs-on: windows-latest
96105
needs: check_source
97106
if: needs.check_source.outputs.run_tests == 'true'
107+
env:
108+
IncludeUwp: 'true'
98109
steps:
99110
- uses: actions/checkout@v2
100111
- name: Build CPython
@@ -109,6 +120,8 @@ jobs:
109120
runs-on: windows-latest
110121
needs: check_source
111122
if: needs.check_source.outputs.run_tests == 'true'
123+
env:
124+
IncludeUwp: 'true'
112125
steps:
113126
- uses: actions/checkout@v2
114127
- name: Register MSVC problem matcher
@@ -175,13 +188,28 @@ jobs:
175188
echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
176189
- name: Configure ccache action
177190
uses: hendrikmuhs/ccache-action@v1
178-
- name: Configure CPython
179-
run: ./configure --with-pydebug --with-openssl=$OPENSSL_DIR
180-
- name: Build CPython
191+
- name: Setup directory envs for out-of-tree builds
192+
run: |
193+
echo "CPYTHON_RO_SRCDIR=$(realpath -m ${GITHUB_WORKSPACE}/../cpython-ro-srcdir)" >> $GITHUB_ENV
194+
echo "CPYTHON_BUILDDIR=$(realpath -m ${GITHUB_WORKSPACE}/../cpython-builddir)" >> $GITHUB_ENV
195+
- name: Create directories for read-only out-of-tree builds
196+
run: mkdir -p $CPYTHON_RO_SRCDIR $CPYTHON_BUILDDIR
197+
- name: Bind mount sources read-only
198+
run: sudo mount --bind -o ro $GITHUB_WORKSPACE $CPYTHON_RO_SRCDIR
199+
- name: Configure CPython out-of-tree
200+
working-directory: ${{ env.CPYTHON_BUILDDIR }}
201+
run: ../cpython-ro-srcdir/configure --with-pydebug --with-openssl=$OPENSSL_DIR
202+
- name: Build CPython out-of-tree
203+
working-directory: ${{ env.CPYTHON_BUILDDIR }}
181204
run: make -j4
182205
- name: Display build info
206+
working-directory: ${{ env.CPYTHON_BUILDDIR }}
183207
run: make pythoninfo
208+
- name: Remount sources writable for tests
209+
# some tests write to srcdir, lack of pyc files slows down testing
210+
run: sudo mount $CPYTHON_RO_SRCDIR -oremount,rw
184211
- name: Tests
212+
working-directory: ${{ env.CPYTHON_BUILDDIR }}
185213
run: xvfb-run make buildbottest TESTOPTS="-j4 -uall,-cpu"
186214

187215
build_ubuntu_ssltests:

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*.so.*
1111
*.dylib
1212
*.dll
13+
*.wasm
1314
*.orig
1415
*.pyc
1516
*.pyd
@@ -76,6 +77,7 @@ Misc/python-embed.pc
7677
Misc/python-config.sh
7778
Modules/Setup.config
7879
Modules/Setup.local
80+
Modules/Setup.stdlib
7981
Modules/config.c
8082
Modules/ld_so_aix
8183
Programs/_freeze_module
@@ -113,6 +115,8 @@ Tools/unicode/data/
113115
/config.log
114116
/config.status
115117
/config.status.lineno
118+
# hendrikmuhs/ccache-action@v1
119+
/.ccache
116120
/platform
117121
/profile-clean-stamp
118122
/profile-run-stamp

Doc/Makefile

+4
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ suspicious:
117117
"or in build/$(BUILDER)/suspicious.csv. If all issues are false" \
118118
"positives, append that file to tools/susp-ignored.csv."; \
119119
false; }
120+
@echo "⚠ make suspicious is deprecated and will be removed soon."
121+
@echo "⚠ Use:"
122+
@echo "⚠ make check"
123+
@echo "⚠ instead."
120124

121125
coverage: BUILDER = coverage
122126
coverage: build

Doc/c-api/exceptions.rst

+6-1
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,6 @@ Querying the error indicator
482482
to an exception that was *already caught*, not to an exception that was
483483
freshly raised. This function steals the references of the arguments.
484484
To clear the exception state, pass ``NULL`` for all three arguments.
485-
For general rules about the three arguments, see :c:func:`PyErr_Restore`.
486485
487486
.. note::
488487
@@ -493,6 +492,12 @@ Querying the error indicator
493492
494493
.. versionadded:: 3.3
495494
495+
.. versionchanged:: 3.11
496+
The ``type`` and ``traceback`` arguments are no longer used and
497+
can be NULL. The interpreter now derives them from the exception
498+
instance (the ``value`` argument). The function still steals
499+
references of all three arguments.
500+
496501
497502
Signal Handling
498503
===============

Doc/c-api/init_config.rst

+34-16
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,9 @@ PyConfig
479479
480480
Fields which are already initialized are left unchanged.
481481
482+
Fields for :ref:`path configuration <init-path-config>` are no longer
483+
calculated or modified when calling this function, as of Python 3.11.
484+
482485
The :c:func:`PyConfig_Read` function only parses
483486
:c:member:`PyConfig.argv` arguments once: :c:member:`PyConfig.parse_argv`
484487
is set to ``2`` after arguments are parsed. Since Python arguments are
@@ -493,6 +496,12 @@ PyConfig
493496
parsed, and arguments are only parsed if
494497
:c:member:`PyConfig.parse_argv` equals ``1``.
495498
499+
.. versionchanged:: 3.11
500+
:c:func:`PyConfig_Read` no longer calculates all paths, and so fields
501+
listed under :ref:`Python Path Configuration <init-path-config>` may
502+
no longer be updated until :c:func:`Py_InitializeFromConfig` is
503+
called.
504+
496505
.. c:function:: void PyConfig_Clear(PyConfig *config)
497506
498507
Release configuration memory.
@@ -596,13 +605,16 @@ PyConfig
596605
597606
.. versionadded:: 3.10
598607
599-
.. c:member:: int no_debug_ranges
608+
.. c:member:: int code_debug_ranges
600609
601-
If equals to ``1``, disables the inclusion of the end line and column
610+
If equals to ``0``, disables the inclusion of the end line and column
602611
mappings in code objects. Also disables traceback printing carets to
603612
specific error locations.
604613
605-
Default: ``0``.
614+
Set to ``0`` by the :envvar:`PYTHONNODEBUGRANGES` environment variable
615+
and by the :option:`-X no_debug_ranges <-X>` command line option.
616+
617+
Default: ``1``.
606618
607619
.. versionadded:: 3.11
608620
@@ -845,12 +857,19 @@ PyConfig
845857
846858
Default: value of the ``PLATLIBDIR`` macro which is set by the
847859
:option:`configure --with-platlibdir option <--with-platlibdir>`
848-
(default: ``"lib"``).
860+
(default: ``"lib"``, or ``"DLLs"`` on Windows).
849861
850862
Part of the :ref:`Python Path Configuration <init-path-config>` input.
851863
852864
.. versionadded:: 3.9
853865
866+
.. versionchanged:: 3.11
867+
This macro is now used on Windows to locate the standard
868+
library extension modules, typically under ``DLLs``. However,
869+
for compatibility, note that this value is ignored for any
870+
non-standard layouts, including in-tree builds and virtual
871+
environments.
872+
854873
.. c:member:: wchar_t* pythonpath_env
855874
856875
Module search paths (:data:`sys.path`) as a string separated by ``DELIM``
@@ -867,9 +886,9 @@ PyConfig
867886
868887
Module search paths: :data:`sys.path`.
869888
870-
If :c:member:`~PyConfig.module_search_paths_set` is equal to 0, the
871-
function calculating the :ref:`Python Path Configuration <init-path-config>`
872-
overrides the :c:member:`~PyConfig.module_search_paths` and sets
889+
If :c:member:`~PyConfig.module_search_paths_set` is equal to 0,
890+
:c:func:`Py_InitializeFromConfig` will replace
891+
:c:member:`~PyConfig.module_search_paths` and sets
873892
:c:member:`~PyConfig.module_search_paths_set` to ``1``.
874893
875894
Default: empty list (``module_search_paths``) and ``0``
@@ -941,16 +960,16 @@ PyConfig
941960
942961
.. c:member:: int pathconfig_warnings
943962
944-
On Unix, if non-zero, calculating the :ref:`Python Path Configuration
945-
<init-path-config>` can log warnings into ``stderr``. If equals to 0,
946-
suppress these warnings.
947-
948-
It has no effect on Windows.
963+
If non-zero, calculation of path configuration is allowed to log
964+
warnings into ``stderr``. If equals to 0, suppress these warnings.
949965
950966
Default: ``1`` in Python mode, ``0`` in isolated mode.
951967
952968
Part of the :ref:`Python Path Configuration <init-path-config>` input.
953969
970+
.. versionchanged:: 3.11
971+
Now also applies on Windows.
972+
954973
.. c:member:: wchar_t* prefix
955974
956975
The site-specific directory prefix where the platform independent Python
@@ -1302,10 +1321,9 @@ variables, command line arguments (:c:member:`PyConfig.argv` is not parsed)
13021321
and user site directory. The C standard streams (ex: ``stdout``) and the
13031322
LC_CTYPE locale are left unchanged. Signal handlers are not installed.
13041323
1305-
Configuration files are still used with this configuration. Set the
1306-
:ref:`Python Path Configuration <init-path-config>` ("output fields") to ignore these
1307-
configuration files and avoid the function computing the default path
1308-
configuration.
1324+
Configuration files are still used with this configuration to determine
1325+
paths that are unspecified. Ensure :c:member:`PyConfig.home` is specified
1326+
to avoid computing the default path configuration.
13091327
13101328
13111329
.. _init-python-config:

Doc/c-api/iter.rst

+7-6
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ There are two functions specifically for working with iterators.
99

1010
.. c:function:: int PyIter_Check(PyObject *o)
1111
12-
Return non-zero if the object *o* supports the iterator protocol, and ``0``
13-
otherwise. This function always succeeds.
12+
Return non-zero if the object *o* can be safely passed to
13+
:c:func:`PyIter_Next`, and ``0`` otherwise. This function always succeeds.
1414
1515
.. c:function:: int PyAIter_Check(PyObject *o)
1616
@@ -21,10 +21,11 @@ There are two functions specifically for working with iterators.
2121
2222
.. c:function:: PyObject* PyIter_Next(PyObject *o)
2323
24-
Return the next value from the iteration *o*. The object must be an iterator
25-
(it is up to the caller to check this). If there are no remaining values,
26-
returns ``NULL`` with no exception set. If an error occurs while retrieving
27-
the item, returns ``NULL`` and passes along the exception.
24+
Return the next value from the iterator *o*. The object must be an iterator
25+
according to :c:func:`PyIter_Check` (it is up to the caller to check this).
26+
If there are no remaining values, returns ``NULL`` with no exception set.
27+
If an error occurs while retrieving the item, returns ``NULL`` and passes
28+
along the exception.
2829
2930
To write a loop which iterates over an iterator, the C code should look
3031
something like this::

Doc/c-api/typeobj.rst

+7-7
Original file line numberDiff line numberDiff line change
@@ -1521,9 +1521,9 @@ and :c:type:`PyType_Type` effectively act as defaults.)
15211521

15221522
.. c:member:: getiterfunc PyTypeObject.tp_iter
15231523
1524-
An optional pointer to a function that returns an iterator for the object. Its
1525-
presence normally signals that the instances of this type are iterable (although
1526-
sequences may be iterable without this function).
1524+
An optional pointer to a function that returns an :term:`iterator` for the
1525+
object. Its presence normally signals that the instances of this type are
1526+
:term:`iterable` (although sequences may be iterable without this function).
15271527

15281528
This function has the same signature as :c:func:`PyObject_GetIter`::
15291529

@@ -1536,8 +1536,8 @@ and :c:type:`PyType_Type` effectively act as defaults.)
15361536

15371537
.. c:member:: iternextfunc PyTypeObject.tp_iternext
15381538
1539-
An optional pointer to a function that returns the next item in an iterator.
1540-
The signature is::
1539+
An optional pointer to a function that returns the next item in an
1540+
:term:`iterator`. The signature is::
15411541

15421542
PyObject *tp_iternext(PyObject *self);
15431543

@@ -2429,8 +2429,8 @@ Async Object Structures
24292429

24302430
PyObject *am_await(PyObject *self);
24312431

2432-
The returned object must be an iterator, i.e. :c:func:`PyIter_Check` must
2433-
return ``1`` for it.
2432+
The returned object must be an :term:`iterator`, i.e. :c:func:`PyIter_Check`
2433+
must return ``1`` for it.
24342434

24352435
This slot may be set to ``NULL`` if an object is not an :term:`awaitable`.
24362436

Doc/faq/library.rst

+2-5
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,6 @@ Be sure to use the :mod:`threading` module and not the :mod:`_thread` module.
240240
The :mod:`threading` module builds convenient abstractions on top of the
241241
low-level primitives provided by the :mod:`_thread` module.
242242
243-
Aahz has a set of slides from his threading tutorial that are helpful; see
244-
http://www.pythoncraft.com/OSCON2001/.
245-
246243
247244
None of my threads seem to run: why?
248245
------------------------------------
@@ -614,9 +611,9 @@ use ``p.read(n)``.
614611
How do I access the serial (RS232) port?
615612
----------------------------------------
616613
617-
For Win32, POSIX (Linux, BSD, etc.), Jython:
614+
For Win32, OSX, Linux, BSD, Jython, IronPython:
618615
619-
http://pyserial.sourceforge.net
616+
https://pypi.org/project/pyserial/
620617
621618
For Unix, see a Usenet post by Mitch Chapman:
622619

Doc/faq/programming.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -2092,7 +2092,7 @@ Jim Roskind suggests performing steps in the following order in each module:
20922092
* ``import`` statements
20932093
* active code (including globals that are initialized from imported values).
20942094

2095-
van Rossum doesn't like this approach much because the imports appear in a
2095+
Van Rossum doesn't like this approach much because the imports appear in a
20962096
strange place, but it does work.
20972097

20982098
Matthias Urlichs recommends restructuring your code so that the recursive import

Doc/glossary.rst

+5
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,11 @@ Glossary
659659

660660
More information can be found in :ref:`typeiter`.
661661

662+
.. impl-detail::
663+
664+
CPython does not consistently apply the requirement that an iterator
665+
define :meth:`__iter__`.
666+
662667
key function
663668
A key function or collation function is a callable that returns a value
664669
used for sorting or ordering. For example, :func:`locale.strxfrm` is

Doc/howto/annotations.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ Manually Un-Stringizing Stringized Annotations
156156
require annotating with string values that specifically
157157
*can't* be evaluated. For example:
158158

159-
* :pep:`604` union types using `|`, before support for this
159+
* :pep:`604` union types using ``|``, before support for this
160160
was added to Python 3.10.
161161
* Definitions that aren't needed at runtime, only imported
162162
when :const:`typing.TYPE_CHECKING` is true.

0 commit comments

Comments
 (0)