Skip to content

Commit 3722b64

Browse files
committed
Merge branch 'main' into pythongh-77609-glob-follow-symlinks
2 parents 6c61822 + cb88ae6 commit 3722b64

File tree

125 files changed

+4438
-2134
lines changed

Some content is hidden

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

125 files changed

+4438
-2134
lines changed

Diff for: .github/dependabot.yml

+7
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,10 @@ updates:
1212
update-types:
1313
- "version-update:semver-minor"
1414
- "version-update:semver-patch"
15+
- package-ecosystem: "pip"
16+
directory: "/Tools/clinic/"
17+
schedule:
18+
interval: "monthly"
19+
labels:
20+
- "skip issue"
21+
- "skip news"

Diff for: .github/workflows/build.yml

+98
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ jobs:
3636
timeout-minutes: 10
3737
outputs:
3838
run_tests: ${{ steps.check.outputs.run_tests }}
39+
run_hypothesis: ${{ steps.check.outputs.run_hypothesis }}
3940
steps:
4041
- uses: actions/checkout@v3
4142
- name: Check for source changes
@@ -61,6 +62,17 @@ jobs:
6162
git diff --name-only origin/$GITHUB_BASE_REF.. | grep -qvE '(\.rst$|^Doc|^Misc)' && echo "run_tests=true" >> $GITHUB_OUTPUT || true
6263
fi
6364
65+
# Check if we should run hypothesis tests
66+
GIT_BRANCH=${GITHUB_BASE_REF:-${GITHUB_REF#refs/heads/}}
67+
echo $GIT_BRANCH
68+
if $(echo "$GIT_BRANCH" | grep -q -w '3\.\(8\|9\|10\|11\)'); then
69+
echo "Branch too old for hypothesis tests"
70+
echo "run_hypothesis=false" >> $GITHUB_OUTPUT
71+
else
72+
echo "Run hypothesis tests"
73+
echo "run_hypothesis=true" >> $GITHUB_OUTPUT
74+
fi
75+
6476
check_generated_files:
6577
name: 'Check if generated files are up to date'
6678
runs-on: ubuntu-latest
@@ -291,6 +303,92 @@ jobs:
291303
- name: SSL tests
292304
run: ./python Lib/test/ssltests.py
293305

306+
test_hypothesis:
307+
name: "Hypothesis Tests on Ubuntu"
308+
runs-on: ubuntu-20.04
309+
timeout-minutes: 60
310+
needs: check_source
311+
if: needs.check_source.outputs.run_tests == 'true' && needs.check_source.outputs.run_hypothesis == 'true'
312+
env:
313+
OPENSSL_VER: 1.1.1t
314+
PYTHONSTRICTEXTENSIONBUILD: 1
315+
steps:
316+
- uses: actions/checkout@v3
317+
- name: Register gcc problem matcher
318+
run: echo "::add-matcher::.github/problem-matchers/gcc.json"
319+
- name: Install Dependencies
320+
run: sudo ./.github/workflows/posix-deps-apt.sh
321+
- name: Configure OpenSSL env vars
322+
run: |
323+
echo "MULTISSL_DIR=${GITHUB_WORKSPACE}/multissl" >> $GITHUB_ENV
324+
echo "OPENSSL_DIR=${GITHUB_WORKSPACE}/multissl/openssl/${OPENSSL_VER}" >> $GITHUB_ENV
325+
echo "LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/multissl/openssl/${OPENSSL_VER}/lib" >> $GITHUB_ENV
326+
- name: 'Restore OpenSSL build'
327+
id: cache-openssl
328+
uses: actions/cache@v3
329+
with:
330+
path: ./multissl/openssl/${{ env.OPENSSL_VER }}
331+
key: ${{ runner.os }}-multissl-openssl-${{ env.OPENSSL_VER }}
332+
- name: Install OpenSSL
333+
if: steps.cache-openssl.outputs.cache-hit != 'true'
334+
run: python3 Tools/ssl/multissltests.py --steps=library --base-directory $MULTISSL_DIR --openssl $OPENSSL_VER --system Linux
335+
- name: Add ccache to PATH
336+
run: |
337+
echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
338+
- name: Configure ccache action
339+
uses: hendrikmuhs/[email protected]
340+
- name: Setup directory envs for out-of-tree builds
341+
run: |
342+
echo "CPYTHON_RO_SRCDIR=$(realpath -m ${GITHUB_WORKSPACE}/../cpython-ro-srcdir)" >> $GITHUB_ENV
343+
echo "CPYTHON_BUILDDIR=$(realpath -m ${GITHUB_WORKSPACE}/../cpython-builddir)" >> $GITHUB_ENV
344+
- name: Create directories for read-only out-of-tree builds
345+
run: mkdir -p $CPYTHON_RO_SRCDIR $CPYTHON_BUILDDIR
346+
- name: Bind mount sources read-only
347+
run: sudo mount --bind -o ro $GITHUB_WORKSPACE $CPYTHON_RO_SRCDIR
348+
- name: Configure CPython out-of-tree
349+
working-directory: ${{ env.CPYTHON_BUILDDIR }}
350+
run: ../cpython-ro-srcdir/configure --with-pydebug --with-openssl=$OPENSSL_DIR
351+
- name: Build CPython out-of-tree
352+
working-directory: ${{ env.CPYTHON_BUILDDIR }}
353+
run: make -j4
354+
- name: Display build info
355+
working-directory: ${{ env.CPYTHON_BUILDDIR }}
356+
run: make pythoninfo
357+
- name: Remount sources writable for tests
358+
# some tests write to srcdir, lack of pyc files slows down testing
359+
run: sudo mount $CPYTHON_RO_SRCDIR -oremount,rw
360+
- name: Setup directory envs for out-of-tree builds
361+
run: |
362+
echo "CPYTHON_BUILDDIR=$(realpath -m ${GITHUB_WORKSPACE}/../cpython-builddir)" >> $GITHUB_ENV
363+
- name: "Create hypothesis venv"
364+
working-directory: ${{ env.CPYTHON_BUILDDIR }}
365+
run: |
366+
VENV_LOC=$(realpath -m .)/hypovenv
367+
VENV_PYTHON=$VENV_LOC/bin/python
368+
echo "HYPOVENV=${VENV_LOC}" >> $GITHUB_ENV
369+
echo "VENV_PYTHON=${VENV_PYTHON}" >> $GITHUB_ENV
370+
./python -m venv $VENV_LOC && $VENV_PYTHON -m pip install -U hypothesis
371+
- name: "Run tests"
372+
working-directory: ${{ env.CPYTHON_BUILDDIR }}
373+
run: |
374+
# Most of the excluded tests are slow test suites with no property tests
375+
#
376+
# (GH-104097) test_sysconfig is skipped because it has tests that are
377+
# failing when executed from inside a virtual environment.
378+
${{ env.VENV_PYTHON }} -m test \
379+
-W \
380+
-o \
381+
-j4 \
382+
-x test_asyncio \
383+
-x test_multiprocessing_fork \
384+
-x test_multiprocessing_forkserver \
385+
-x test_multiprocessing_spawn \
386+
-x test_concurrent_futures \
387+
-x test_socket \
388+
-x test_subprocess \
389+
-x test_signal \
390+
-x test_sysconfig
391+
294392
295393
build_asan:
296394
name: 'Address sanitizer'

Diff for: .github/workflows/mypy.yml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Workflow to run mypy on select parts of the CPython repo
2+
name: mypy
3+
4+
on:
5+
push:
6+
branches:
7+
- main
8+
pull_request:
9+
paths:
10+
- "Tools/clinic/**"
11+
- ".github/workflows/mypy.yml"
12+
workflow_dispatch:
13+
14+
permissions:
15+
contents: read
16+
17+
env:
18+
PIP_DISABLE_PIP_VERSION_CHECK: 1
19+
FORCE_COLOR: 1
20+
TERM: xterm-256color # needed for FORCE_COLOR to work on mypy on Ubuntu, see https://github.com/python/mypy/issues/13817
21+
22+
concurrency:
23+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
24+
cancel-in-progress: true
25+
26+
jobs:
27+
mypy:
28+
name: Run mypy on Tools/clinic/
29+
runs-on: ubuntu-latest
30+
timeout-minutes: 10
31+
steps:
32+
- uses: actions/checkout@v3
33+
- uses: actions/setup-python@v4
34+
with:
35+
python-version: "3.x"
36+
cache: pip
37+
cache-dependency-path: Tools/clinic/requirements-dev.txt
38+
- run: pip install -r Tools/clinic/requirements-dev.txt
39+
- run: mypy --config-file Tools/clinic/mypy.ini

Diff for: Doc/howto/clinic.rst

+3
Original file line numberDiff line numberDiff line change
@@ -775,6 +775,9 @@ All Argument Clinic converters accept the following arguments:
775775
because :pep:`8` mandates that the Python library may not use
776776
annotations.
777777

778+
``unused``
779+
Wrap the argument with :c:macro:`Py_UNUSED` in the impl function signature.
780+
778781
In addition, some converters accept additional arguments. Here is a list
779782
of these arguments, along with their meanings:
780783

Diff for: Doc/library/atexit.rst

+3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ at interpreter termination time they will be run in the order ``C``, ``B``,
2020
program is killed by a signal not handled by Python, when a Python fatal
2121
internal error is detected, or when :func:`os._exit` is called.
2222

23+
**Note:** The effect of registering or unregistering functions from within
24+
a cleanup function is undefined.
25+
2326
.. versionchanged:: 3.7
2427
When used with C-API subinterpreters, registered functions
2528
are local to the interpreter they were registered in.

Diff for: Doc/library/functions.rst

+7
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,13 @@ are always available. They are listed here in alphabetical order.
168168
If :func:`sys.breakpointhook` is not accessible, this function will
169169
raise :exc:`RuntimeError`.
170170

171+
By default, the behavior of :func:`breakpoint` can be changed with
172+
the :envvar:`PYTHONBREAKPOINT` environment variable.
173+
See :func:`sys.breakpointhook` for usage details.
174+
175+
Note that this is not guaranteed if :func:`sys.breakpointhook`
176+
has been replaced.
177+
171178
.. audit-event:: builtins.breakpoint breakpointhook breakpoint
172179

173180
.. versionadded:: 3.7

Diff for: Doc/library/pdb.rst

+11-3
Original file line numberDiff line numberDiff line change
@@ -602,9 +602,17 @@ can be overridden by the local file.
602602

603603
Execute the (one-line) *statement* in the context of the current stack frame.
604604
The exclamation point can be omitted unless the first word of the statement
605-
resembles a debugger command. To set a global variable, you can prefix the
606-
assignment command with a :keyword:`global` statement on the same line,
607-
e.g.::
605+
resembles a debugger command, e.g.:
606+
607+
.. code-block:: none
608+
609+
(Pdb) ! n=42
610+
(Pdb)
611+
612+
To set a global variable, you can prefix the assignment command with a
613+
:keyword:`global` statement on the same line, e.g.:
614+
615+
.. code-block:: none
608616
609617
(Pdb) global list_options; list_options = ['-l']
610618
(Pdb)

Diff for: Doc/library/random.rst

+6-3
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,10 @@ be found in any statistics text.
334334

335335
.. function:: gammavariate(alpha, beta)
336336

337-
Gamma distribution. (*Not* the gamma function!) Conditions on the
338-
parameters are ``alpha > 0`` and ``beta > 0``.
337+
Gamma distribution. (*Not* the gamma function!) The shape and
338+
scale parameters, *alpha* and *beta*, must have positive values.
339+
(Calling conventions vary and some sources define 'beta'
340+
as the inverse of the scale).
339341

340342
The probability distribution function is::
341343

@@ -346,7 +348,8 @@ be found in any statistics text.
346348

347349
.. function:: gauss(mu=0.0, sigma=1.0)
348350

349-
Normal distribution, also called the Gaussian distribution. *mu* is the mean,
351+
Normal distribution, also called the Gaussian distribution.
352+
*mu* is the mean,
350353
and *sigma* is the standard deviation. This is slightly faster than
351354
the :func:`normalvariate` function defined below.
352355

Diff for: Doc/library/sqlite3.rst

+4-1
Original file line numberDiff line numberDiff line change
@@ -1694,7 +1694,10 @@ Cursor objects
16941694
``INSERT``, ``UPDATE``, ``DELETE``, and ``REPLACE`` statements;
16951695
is ``-1`` for other statements,
16961696
including :abbr:`CTE (Common Table Expression)` queries.
1697-
It is only updated by the :meth:`execute` and :meth:`executemany` methods.
1697+
It is only updated by the :meth:`execute` and :meth:`executemany` methods,
1698+
after the statement has run to completion.
1699+
This means that any resulting rows must be fetched in order for
1700+
:attr:`!rowcount` to be updated.
16981701

16991702
.. attribute:: row_factory
17001703

Diff for: Doc/library/typing.rst

+6-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
This module provides runtime support for type hints. The most fundamental
2121
support consists of the types :data:`Any`, :data:`Union`, :data:`Callable`,
22-
:class:`TypeVar`, and :class:`Generic`. For a full specification, please see
22+
:class:`TypeVar`, and :class:`Generic`. For a specification, please see
2323
:pep:`484`. For a simplified introduction to type hints, see :pep:`483`.
2424

2525

@@ -592,7 +592,7 @@ The module defines the following classes, functions and decorators.
592592
when the checked program targets Python 3.9 or newer.
593593

594594
The deprecated types will be removed from the :mod:`typing` module
595-
in the first Python version released 5 years after the release of Python 3.9.0.
595+
no sooner than the first Python version released 5 years after the release of Python 3.9.0.
596596
See details in :pep:`585`—*Type Hinting Generics In Standard Collections*.
597597

598598

@@ -1291,6 +1291,8 @@ These are not used in annotations. They are building blocks for creating generic
12911291
U = TypeVar('U', bound=str|bytes) # Can be any subtype of the union str|bytes
12921292
V = TypeVar('V', bound=SupportsAbs) # Can be anything with an __abs__ method
12931293

1294+
.. _typing-constrained-typevar:
1295+
12941296
Using a *constrained* type variable, however, means that the ``TypeVar``
12951297
can only ever be solved as being exactly one of the constraints given::
12961298

@@ -1550,7 +1552,7 @@ These are not used in annotations. They are building blocks for creating generic
15501552

15511553
.. data:: AnyStr
15521554

1553-
``AnyStr`` is a :class:`constrained type variable <TypeVar>` defined as
1555+
``AnyStr`` is a :ref:`constrained type variable <typing-constrained-typevar>` defined as
15541556
``AnyStr = TypeVar('AnyStr', str, bytes)``.
15551557

15561558
It is meant to be used for functions that may accept any kind of string
@@ -2112,7 +2114,7 @@ Other concrete types
21122114
Python 2 is no longer supported, and most type checkers also no longer
21132115
support type checking Python 2 code. Removal of the alias is not
21142116
currently planned, but users are encouraged to use
2115-
:class:`str` instead of ``Text`` wherever possible.
2117+
:class:`str` instead of ``Text``.
21162118

21172119
Abstract Base Classes
21182120
---------------------

Diff for: Doc/whatsnew/3.12.rst

+5
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,9 @@ Pending Removal in Python 3.14
831831
For use in typing, prefer a union, like ``bytes | bytearray``, or :class:`collections.abc.Buffer`.
832832
(Contributed by Shantanu Jain in :gh:`91896`.)
833833

834+
* :class:`typing.ByteString`, deprecated since Python 3.9, now causes a
835+
:exc:`DeprecationWarning` to be emitted when it is used.
836+
834837
* Creating immutable types (:data:`Py_TPFLAGS_IMMUTABLETYPE`) with mutable
835838
bases using the C API.
836839

@@ -1201,6 +1204,8 @@ Build Changes
12011204

12021205
(Contributed by Zhang Na in :gh:`90656`.)
12031206

1207+
* ``PYTHON_FOR_REGEN`` now require Python 3.10 or newer.
1208+
12041209

12051210
C API Changes
12061211
=============

Diff for: Include/internal/pycore_code.h

+2-5
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,6 @@ typedef struct {
5353

5454
typedef struct {
5555
uint16_t counter;
56-
uint16_t class_version[2];
57-
uint16_t self_type_version[2];
58-
uint16_t method[4];
5956
} _PySuperAttrCache;
6057

6158
#define INLINE_CACHE_ENTRIES_LOAD_SUPER_ATTR CACHE_ENTRIES(_PySuperAttrCache)
@@ -227,8 +224,8 @@ extern int _PyLineTable_PreviousAddressRange(PyCodeAddressRange *range);
227224

228225
/* Specialization functions */
229226

230-
extern void _Py_Specialize_LoadSuperAttr(PyObject *global_super, PyObject *cls, PyObject *self,
231-
_Py_CODEUNIT *instr, PyObject *name, int load_method);
227+
extern void _Py_Specialize_LoadSuperAttr(PyObject *global_super, PyObject *cls,
228+
_Py_CODEUNIT *instr, int load_method);
232229
extern void _Py_Specialize_LoadAttr(PyObject *owner, _Py_CODEUNIT *instr,
233230
PyObject *name);
234231
extern void _Py_Specialize_StoreAttr(PyObject *owner, _Py_CODEUNIT *instr,

Diff for: Include/internal/pycore_frame.h

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ struct _frame {
1919
struct _PyInterpreterFrame *f_frame; /* points to the frame data */
2020
PyObject *f_trace; /* Trace function */
2121
int f_lineno; /* Current line number. Only valid if non-zero */
22-
int f_last_traced_line; /* The last line traced for this frame */
2322
char f_trace_lines; /* Emit per-line trace events? */
2423
char f_trace_opcodes; /* Emit per-opcode trace events? */
2524
char f_fast_as_locals; /* Have the fast locals of this frame been converted to a dict? */

Diff for: Include/internal/pycore_instruments.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,13 @@ _Py_call_instrumentation(PyThreadState *tstate, int event,
6969

7070
extern int
7171
_Py_call_instrumentation_line(PyThreadState *tstate, _PyInterpreterFrame* frame,
72-
_Py_CODEUNIT *instr);
72+
_Py_CODEUNIT *instr, _Py_CODEUNIT *prev);
7373

7474
extern int
7575
_Py_call_instrumentation_instruction(
7676
PyThreadState *tstate, _PyInterpreterFrame* frame, _Py_CODEUNIT *instr);
7777

78-
int
78+
_Py_CODEUNIT *
7979
_Py_call_instrumentation_jump(
8080
PyThreadState *tstate, int event,
8181
_PyInterpreterFrame *frame, _Py_CODEUNIT *instr, _Py_CODEUNIT *target);
@@ -100,6 +100,7 @@ extern int
100100
_Py_Instrumentation_GetLine(PyCodeObject *code, int index);
101101

102102
extern PyObject _PyInstrumentation_MISSING;
103+
extern PyObject _PyInstrumentation_DISABLE;
103104

104105
#ifdef __cplusplus
105106
}

0 commit comments

Comments
 (0)