Skip to content

Commit 8efd7c6

Browse files
committed
Merge branch 'main' into supermon
* main: pythongh-91896: Fixup some docs issues following ByteString deprecation (python#104422) pythonGH-104371: check return value of calling `mv.release` (python#104417) pythongh-104415: Fix refleak tests for `typing.ByteString` deprecation (python#104416) pythonGH-86275: Implementation of hypothesis stubs for property-based tests, with zoneinfo tests (python#22863) pythonGH-103082: Filter LINE events in VM, to simplify tool implementation. (pythonGH-104387) pythongh-93649: Split gc- and allocation tests from _testcapimodule.c (pythonGH-104403) pythongh-104389: Add 'unused' keyword to Argument Clinic C converters (python#104390) pythongh-101819: Prepare _io._IOBase for module state (python#104386) pythongh-104413: Fix refleak when super attribute throws AttributeError (python#104414) Fix refleak in `super_descr_get` (python#104408) pythongh-87526: Remove dead initialization from _zoneinfo parse_abbr() (python#24700) pythongh-91896: Improve visibility of `ByteString` deprecation warnings (python#104294) pythongh-104371: Fix calls to `__release_buffer__` while an exception is active (python#104378) pythongh-104377: fix cell in comprehension that is free in outer scope (python#104394) pythongh-104392: Remove _paramspec_tvars from typing (python#104393) pythongh-104396: uuid.py to skip platform check for emscripten and wasi (pythongh-104397) pythongh-99108: Refresh HACL* from upstream (python#104401) pythongh-104301: Allow leading whitespace in disambiguated pdb statements (python#104342)
2 parents fb47955 + ce4eecf commit 8efd7c6

Some content is hidden

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

60 files changed

+1786
-654
lines changed

.github/workflows/build.yml

+96
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,90 @@ 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+
-x test_asyncio \
381+
-x test_multiprocessing_fork \
382+
-x test_multiprocessing_forkserver \
383+
-x test_multiprocessing_spawn \
384+
-x test_concurrent_futures \
385+
-x test_socket \
386+
-x test_subprocess \
387+
-x test_signal \
388+
-x test_sysconfig
389+
294390
295391
build_asan:
296392
name: 'Address sanitizer'

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

Doc/library/collections.abc.rst

+4-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414

1515
.. testsetup:: *
1616

17-
from collections.abc import *
17+
import warnings
18+
# Ignore warning when ByteString is imported
19+
with warnings.catch_warnings(action='ignore', category=DeprecationWarning):
20+
from collections.abc import *
1821
import itertools
1922
__name__ = '<doctest>'
2023

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)

Doc/whatsnew/3.12.rst

+3
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 an
835+
:exc:`DeprecationWarning` to be emitted when it is used or accessed.
836+
834837
* Creating immutable types (:data:`Py_TPFLAGS_IMMUTABLETYPE`) with mutable
835838
bases using the C API.
836839

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? */

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
}

Lib/collections/abc.py

+9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
11
from _collections_abc import *
22
from _collections_abc import __all__
33
from _collections_abc import _CallableGenericAlias
4+
5+
_deprecated_ByteString = globals().pop("ByteString")
6+
7+
def __getattr__(attr):
8+
if attr == "ByteString":
9+
import warnings
10+
warnings._deprecated("collections.abc.ByteString", remove=(3, 14))
11+
return _deprecated_ByteString
12+
raise AttributeError(f"module 'collections.abc' has no attribute {attr!r}")

Lib/pdb.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ def displayhook(self, obj):
440440
self.message(repr(obj))
441441

442442
def default(self, line):
443-
if line[:1] == '!': line = line[1:]
443+
if line[:1] == '!': line = line[1:].strip()
444444
locals = self.curframe_locals
445445
globals = self.curframe.f_globals
446446
try:
@@ -1642,9 +1642,12 @@ def help_exec(self):
16421642
16431643
Execute the (one-line) statement in the context of the current
16441644
stack frame. The exclamation point can be omitted unless the
1645-
first word of the statement resembles a debugger command. To
1646-
assign to a global variable you must always prefix the command
1647-
with a 'global' command, e.g.:
1645+
first word of the statement resembles a debugger command, e.g.:
1646+
(Pdb) ! n=42
1647+
(Pdb)
1648+
1649+
To assign to a global variable you must always prefix the command with
1650+
a 'global' command, e.g.:
16481651
(Pdb) global list_options; list_options = ['-l']
16491652
(Pdb)
16501653
"""

Lib/pydoc_data/topics.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -5283,11 +5283,14 @@
52835283
'current\n'
52845284
' stack frame. The exclamation point can be omitted unless the '
52855285
'first\n'
5286-
' word of the statement resembles a debugger command. To set '
5287-
'a\n'
5288-
' global variable, you can prefix the assignment command with '
5289-
'a\n'
5290-
' "global" statement on the same line, e.g.:\n'
5286+
' word of the statement resembles a debugger command, e.g.:'
5287+
'\n'
5288+
' (Pdb) ! n=42\n'
5289+
' (Pdb)\n'
5290+
'\n'
5291+
' To set a global variable, you can prefix the assignment command '
5292+
' with \n'
5293+
' a "global" statement on the same line, e.g.:\n'
52915294
'\n'
52925295
" (Pdb) global list_options; list_options = ['-l']\n"
52935296
' (Pdb)\n'

Lib/test/libregrtest/refleak.py

+10-6
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,13 @@ def dash_R(ns, test_name, test_func):
4848
else:
4949
zdc = zipimport._zip_directory_cache.copy()
5050
abcs = {}
51-
for abc in [getattr(collections.abc, a) for a in collections.abc.__all__]:
52-
if not isabstract(abc):
53-
continue
54-
for obj in abc.__subclasses__() + [abc]:
55-
abcs[obj] = _get_dump(obj)[0]
51+
# catch and ignore collections.abc.ByteString deprecation
52+
with warnings.catch_warnings(action='ignore', category=DeprecationWarning):
53+
for abc in [getattr(collections.abc, a) for a in collections.abc.__all__]:
54+
if not isabstract(abc):
55+
continue
56+
for obj in abc.__subclasses__() + [abc]:
57+
abcs[obj] = _get_dump(obj)[0]
5658

5759
# bpo-31217: Integer pool to get a single integer object for the same
5860
# value. The pool is used to prevent false alarm when checking for memory
@@ -173,7 +175,9 @@ def dash_R_cleanup(fs, ps, pic, zdc, abcs):
173175
zipimport._zip_directory_cache.update(zdc)
174176

175177
# Clear ABC registries, restoring previously saved ABC registries.
176-
abs_classes = [getattr(collections.abc, a) for a in collections.abc.__all__]
178+
# ignore deprecation warning for collections.abc.ByteString
179+
with warnings.catch_warnings(action='ignore', category=DeprecationWarning):
180+
abs_classes = [getattr(collections.abc, a) for a in collections.abc.__all__]
177181
abs_classes = filter(isabstract, abs_classes)
178182
for abc in abs_classes:
179183
for obj in abc.__subclasses__() + [abc]:

Lib/test/libregrtest/save_env.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,10 @@ def restore_sysconfig__INSTALL_SCHEMES(self, saved):
257257
sysconfig._INSTALL_SCHEMES.update(saved[2])
258258

259259
def get_files(self):
260+
# XXX: Maybe add an allow-list here?
260261
return sorted(fn + ('/' if os.path.isdir(fn) else '')
261-
for fn in os.listdir())
262+
for fn in os.listdir()
263+
if not fn.startswith(".hypothesis"))
262264
def restore_files(self, saved_value):
263265
fn = os_helper.TESTFN
264266
if fn not in saved_value and (fn + '/') not in saved_value:

0 commit comments

Comments
 (0)