gh-109230: test_pyexpat no longer depends on the current directory (GH-109233)
Fix test_pyexpat.test_exception(): it can now be run from a directory
different than Python source code directory. Before, the test failed
in this case.
Skip the test if Modules/pyexpat.c source is not available. Skip also
the test on Python implementations other than CPython.
(cherry picked from commit e55aab9578)
Co-authored-by: Victor Stinner <vstinner@python.org>
gh-109237: Fix test_site for non-ASCII working directory (GH-109238)
Fix test_site.test_underpth_basic() when the working directory
contains at least one non-ASCII character: encode the "._pth" file to
UTF-8 and enable the UTF-8 Mode to use UTF-8 for the child process
stdout.
(cherry picked from commit cbb3a6f8ad)
Co-authored-by: Victor Stinner <vstinner@python.org>
Improve the sieve() recipe in the itertools docs (gh-109199)
Lazier sieve
(cherry picked from commit d3ed9921cd)
Co-authored-by: Raymond Hettinger <rhettinger@users.noreply.github.com>
Fix an ironic typo in a code comment. (gh-109186)
(cherry picked from commit 75cd86599b)
Co-authored-by: Raymond Hettinger <rhettinger@users.noreply.github.com>
* gh-109118: Fix runtime crash when NameError happens in PEP 695 function (#109123)
(cherry picked from commit 17f994174d)
* [3.12] gh-109118: Fix runtime crash when NameError happens in PEP 695 function (GH-109123).
(cherry picked from commit 17f994174d)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
GH-109067: fix randomly failing `test_async_gen_asyncio_gc_aclose_09` test (GH-109142)
Use `asyncio.sleep(0)` instead of short sleeps.
(cherry picked from commit ccd48623d4)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
gh-109022: [Enum] require `names=()` to create empty enum type (GH-109048)
add guard so that ``Enum('bar')`` raises a TypeError instead of
creating a new enum class called `bar`. To create the new but
empty class, use:
huh = Enum('bar', names=())
(cherry picked from commit c74e440168)
Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
Add version directives to ast docs (GH-108788)
(cherry picked from commit 74fc96bc60)
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
gh-68403: Fix test_coverage in test_trace (GH-108910)
Its behavior no longer affected by test running options such as -m.
(cherry picked from commit 7e1a7abb98)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
gh-75743: Restore test_timeout.testConnectTimeout() (GH-109087)
This un-skips this test now that pythontest.net implements appropriate firewall
rules for it.
(cherry picked from commit 1829a3c9a3)
Co-authored-by: Ee Durbin <ewdurbin@gmail.com>
gh-107924: re-order os.sendfile() flag documentation (GH-107926)
(cherry picked from commit 403ab1306a)
Co-authored-by: Christoph Anton Mitterer <mail@christoph.anton.mitterer.name>
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
gh-102823: Document return type of floor division on floats (GH-102824)
(cherry picked from commit b72251de93)
Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
socket documentation fix - rename triple to 3-tuple (GH-24722)
(cherry picked from commit 6b15ff5235)
Co-authored-by: Ori Hoch <ori@uumpa.com>
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
gh-71770: Add more details on behavior of configparser's default_section (GH-31562)
(cherry picked from commit 891236f482)
Co-authored-by: Stanley <46876382+slateny@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
bpo-38157: Add example about per file output for mock_open. (GH-16090)
(cherry picked from commit e183a71eef)
Co-authored-by: Karthikeyan Singaravelan <tir.karthi@gmail.com>
Co-authored-by: Stanley <46876382+slateny@users.noreply.github.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
gh-103186: Suppress and assert expected RuntimeWarnings in test_sys_settrace (GH-103244)
Caused as a result of frame manipulation where locals are never assigned / initialised.
(cherry picked from commit 3e53ac9903)
Co-authored-by: Ijtaba Hussain <ijtabahussain@live.com>
gh-108740: Fix "make regen-all" race condition (#108741)
Fix a race condition in "make regen-all". The deepfreeze.c source and
files generated by Argument Clinic are now generated or updated
before generating "global objects". Previously, some identifiers may
miss depending on the order in which these files were generated.
* "make regen-global-objects": Make sure that deepfreeze.c is
generated and up to date, and always run "make clinic".
* "make clinic" no longer runs generate_global_objects.py script.
* "make regen-deepfreeze" now only updates deepfreeze.c (C file).
It doesn't build deepfreeze.o (object) anymore.
* Remove misleading messages in "make regen-global-objects" and
"make clinic". They are now outdated, these commands are now
safe to use.
* Document generates files in Doc/using/configure.rst.
Co-authored-by: Erlend E. Aasland <erlend@python.org>
(cherry picked from commit db1ee6a19a)
gh-108851: Fix tomllib recursion tests (GH-108853)
* Add get_recursion_available() and get_recursion_depth() functions
to the test.support module.
* Change infinite_recursion() default max_depth from 75 to 100.
* Fix test_tomllib recursion tests for WASI buildbots: reduce the
recursion limit and compute the maximum nested array/dict depending
on the current available recursion limit.
* test.pythoninfo logs sys.getrecursionlimit().
* Enhance test_sys tests on sys.getrecursionlimit()
and sys.setrecursionlimit().
(cherry picked from commit 8ff1142578)
Co-authored-by: Victor Stinner <vstinner@python.org>
gh-89392: Use unittest test runner for doctests in test_getopt (GH-108916)
(cherry picked from commit f980cc19b9)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
gh-89392: Use normal unittest runner in test_type_cache (GH-108911)
(cherry picked from commit eaabaac7c0)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
gh-91960: Skip test_gdb if gdb cannot retrive Python frames (GH-108999)
Skip test_gdb if gdb is unable to retrieve Python frame objects: if a
frame is "<optimized out>". When Python is built with "clang -Og",
gdb can fail to retrive the 'frame' parameter of
_PyEval_EvalFrameDefault(). In this case, tests like py_bt() are
likely to fail. Without getting access to Python frames,
python-gdb.py is mostly clueless on retrieving the Python traceback.
Moreover, test_gdb is no longer skipped on macOS if Python is built
with Clang.
(cherry picked from commit fbce43a251)
Co-authored-by: Victor Stinner <vstinner@python.org>
gh-108983: Add more PEP 526 tests to `test_grammar` (GH-108984)
(cherry picked from commit 1fb20d42c5)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
gh-108962: Skip test_tempfile.test_flags() if not supported (GH-108964)
Skip test_tempfile.test_flags() if chflags() fails with "OSError:
[Errno 45] Operation not supported" (ex: on FreeBSD 13).
(cherry picked from commit cd2ef21b07)
Co-authored-by: Victor Stinner <vstinner@python.org>
* gh-108834: regrtest reruns failed tests in subprocesses (#108839)
When using --rerun option, regrtest now re-runs failed tests
in verbose mode in fresh worker processes to have more
deterministic behavior. So it can write its final report even
if a test killed a worker progress.
Add --fail-rerun option to regrtest: exit with non-zero exit code
if a test failed pass passed when re-run in verbose mode (in a
fresh process). That's now more useful since tests can pass
when re-run in a fresh worker progress, whereas they failed
when run after other tests when tests are run sequentially.
Rename --verbose2 option (-w) to --rerun. Keep --verbose2 as a
deprecated alias.
Changes:
* Fix and enhance statistics in regrtest summary. Add "(filtered)"
when --match and/or --ignore options are used.
* Add RunTests class.
* Add TestResult.get_rerun_match_tests() method
* Rewrite code to serialize/deserialize worker arguments as JSON
using a new WorkerJob class.
* Fix stats when a test is run with --forever --rerun.
* If failed test names cannot be parsed, log a warning and don't
filter tests.
* test_regrtest.test_rerun_success() now uses a marker file, since
the test is re-run in a separated process.
* Add tests on normalize_test_name() function.
* Add test_success() and test_skip() tests to test_regrtest.
(cherry picked from commit 31c2945f14)
* gh-108834: regrtest --fail-rerun exits with code 5 (#108896)
When the --fail-rerun option is used and a test fails and then pass,
regrtest now uses exit code 5 ("rerun) instead of 2 ("bad test").
(cherry picked from commit 1170d5a292)
* gh-108416: Mark slow but not CPU bound test methods with requires_resource('walltime') (GH-108480)
(cherry picked from commit 1e0d62793a)
* Manually sync Lib/test/libregrtest/ from main
---------
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
gh-107755: Document the correct default value of slice step (GH-107756)
Document the correct default value of slice step.
(cherry picked from commit 9bf350b066)
Co-authored-by: wim glenn <hey@wimglenn.com>
gh-107732: Mention dir support in importlib.resources docs (#107734)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
(cherry picked from commit 9f0c0a46f0)
Co-authored-by: Shahriar Heidrich <smheidrich@weltenfunktion.de>
Docs: Fix typo in datetime.tzinfo docstring (GH-107257)
(cherry picked from commit 60a9eea3f5)
Co-authored-by: Mikhail Samylov <Samylov-Mikhail@yandex.com>
Co-authored-by: Paul Ganssle <1377457+pganssle@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
GH-108202: Document ``calendar``'s command-line interface (GH-109020)
(cherry picked from commit f0f96a9f40)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
GH-90690: Mention removal of ``PRECALL`` in What's New (GH-103910)
(cherry picked from commit f9bd6e49ae)
Co-authored-by: Anthony Shaw <anthony.p.shaw@gmail.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
Output with one wheel:
```
❯ GITHUB_ACTIONS=true ./Tools/build/verify_ensurepip_wheels.py
Verifying checksum for /Volumes/RAMDisk/cpython/Lib/ensurepip/_bundled/pip-23.2.1-py3-none-any.whl.
Expected digest: 7ccf472345f20d35bdc9d1841ff5f313260c2c33fe417f48c30ac46cccabf5be
Actual digest: 7ccf472345f20d35bdc9d1841ff5f313260c2c33fe417f48c30ac46cccabf5be
::notice file=/Volumes/RAMDisk/cpython/Lib/ensurepip/_bundled/pip-23.2.1-py3-none-any.whl::Successfully verified the checksum of the pip wheel.
```
Output with two wheels:
```
❯ GITHUB_ACTIONS=true ./Tools/build/verify_ensurepip_wheels.py
::error file=/Volumes/RAMDisk/cpython/Lib/ensurepip/_bundled/pip-22.0.4-py3-none-any.whl::Found more than one wheel for package pip.
::error file=/Volumes/RAMDisk/cpython/Lib/ensurepip/_bundled/pip-23.2.1-py3-none-any.whl::Found more than one wheel for package pip.
```
Output without wheels:
```
❯ GITHUB_ACTIONS=true ./Tools/build/verify_ensurepip_wheels.py
::error file=::Could not find a pip wheel on disk.
```
(cherry picked from commit f8a047941f)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
gh-107565: Update Windows build to use OpenSSL 3.0.10 (GH-108928)
(cherry picked from commit deea7c8268)
Co-authored-by: Zachary Ware <zach@python.org>