Commit Graph

118604 Commits

Author SHA1 Message Date
Victor Stinner a0773b89df
gh-108753: Enhance pystats (#108754)
Statistics gathering is now off by default. Use the "-X pystats"
command line option or set the new PYTHONSTATS environment variable
to 1 to turn statistics gathering on at Python startup.

Statistics are no longer dumped at exit if statistics gathering was
off or statistics have been cleared.

Changes:

* Add PYTHONSTATS environment variable.
* sys._stats_dump() now returns False if statistics are not dumped
  because they are all equal to zero.
* Add PyConfig._pystats member.
* Add tests on sys functions and on setting PyConfig._pystats to 1.
* Add Include/cpython/pystats.h and Include/internal/pycore_pystats.h
  header files.
* Rename '_py_stats' variable to '_Py_stats'.
* Exclude Include/cpython/pystats.h from the Py_LIMITED_API.
* Move pystats.h include from object.h to Python.h.
* Add _Py_StatsOn() and _Py_StatsOff() functions. Remove
  '_py_stats_struct' variable from the API: make it static in
  specialize.c.
* Document API in Include/pystats.h and Include/cpython/pystats.h.
* Complete pystats documentation in Doc/using/configure.rst.
* Don't write "all zeros" stats: if _stats_off() and _stats_clear()
  or _stats_dump() were called.
* _PyEval_Fini() now always call _Py_PrintSpecializationStats() which
  does nothing if stats are all zeros.

Co-authored-by: Michael Droettboom <mdboom@gmail.com>
2023-09-06 15:54:59 +00:00
Victor Stinner 8ff1142578
gh-108851: Fix tomllib recursion tests (#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().
2023-09-06 17:34:31 +02:00
Ed Maste 2cd170db40
gh-91960: Add FreeBSD build and test using Cirrus-CI (#91961)
Cirrus-CI is a hosted CI service that supports FreeBSD, Linux, macOS,
and Windows.  Add a .cirrus.yml configuration file to provide CI coverage
on pull requests for FreeBSD 13.2.

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-09-06 16:57:40 +02:00
Łukasz Langa f8a047941f
gh-109002: Ensure only one wheel for each vendored package (#109003)
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.
```
2023-09-06 16:49:44 +02:00
Victor Stinner fbce43a251
gh-91960: Skip test_gdb if gdb cannot retrive Python frames (#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.
2023-09-06 14:34:35 +00:00
Victor Stinner a8cae4071c
gh-107219: Fix concurrent.futures terminate_broken() (#108974)
Fix a race condition in _ExecutorManagerThread.terminate_broken():
ignore the InvalidStateError on future.set_exception(). It can happen
if the future is cancelled before the caller.

Moreover, test_crash_big_data() now waits explicitly until the
executor completes.
2023-09-06 15:57:01 +02:00
Victor Stinner b298b395e8
gh-108765: Cleanup #include in Python/*.c files (#108977)
Mention one symbol imported by each #include.
2023-09-06 15:56:08 +02:00
Victor Stinner 14d6e197cc
gh-108303: Create Lib/test/test_dataclasses/ directory (#108978)
Move test_dataclasses.py and its "dataclass_*.py" modules into the
new Lib/test/test_dataclasses/ subdirectory.
2023-09-06 15:54:16 +02:00
Nikita Sobolev 1fb20d42c5
gh-108983: Add more PEP 526 tests to `test_grammar` (#108984) 2023-09-06 06:41:38 -07:00
Irit Katriel 39376cb93d
gh-108991: replace _PyFrame_GetState by two simpler functions (#108992) 2023-09-06 12:54:59 +01:00
Matthias Bussonnier 5f3433f210
gh-106670: Fix Pdb handling of chained Exceptions with no stacks. (#108865) 2023-09-06 09:41:56 +00:00
KH 44892b1c52
Fix a typo in umarshal.py (#108803)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2023-09-06 09:06:41 +00:00
Nikita Sobolev 65a2bce704
gh-108717: Speedup `os.DirEntry.is_junction` function (#108718) 2023-09-06 08:52:53 +00:00
nabin2004 6f8411cfd6
gh-108857: improve markup in inspect.Signature.replace() docs (#108862) 2023-09-05 17:27:59 -07:00
Victor Stinner cd2ef21b07
gh-108962: Skip test_tempfile.test_flags() if not supported (#108964)
Skip test_tempfile.test_flags() if chflags() fails with "OSError:
[Errno 45] Operation not supported" (ex: on FreeBSD 13).
2023-09-05 21:59:40 +00:00
Guido van Rossum b87263be9b
gh-106581: Support multiple uops pushing new values (#108895)
Also avoid the need for the awkward .clone() call in the argument
to mgr.adjust_inverse() and mgr.adjust().
2023-09-05 13:58:39 -07:00
Anthony Shaw 2c4c26c4ce
gh-108469: Update ast.unparse for unescaped quote support from PEP701 [3.12] (#108553)
Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
2023-09-05 21:01:23 +01:00
wim glenn 9bf350b066
gh-107755: Document the correct default value of slice step (GH-107756)
Document the correct default value of slice step.
2023-09-05 21:22:27 +02:00
Nikita Sobolev 3f89b25763
gh-108927: Fix test_import + test_importlib + test_unittest problem (#108929) 2023-09-05 18:57:48 +00:00
Zachary Ware deea7c8268
gh-107565: Update Windows build to use OpenSSL 3.0.10 (GH-108928)
Also clean up some intermediate NEWS entries about previous versions.
2023-09-05 16:03:06 +00:00
Nikita Sobolev ad1d6a1c20
gh-108903: Remove unneeded `lambda`s from `asyncio` (GH-108904) 2023-09-05 18:11:12 +03:00
Serhiy Storchaka 1e0d62793a
gh-108416: Mark slow but not CPU bound test methods with requires_resource('walltime') (GH-108480) 2023-09-05 17:56:30 +03:00
Serhiy Storchaka f980cc19b9
gh-89392: Use unittest test runner for doctests in test_getopt (GH-108916) 2023-09-05 17:35:28 +03:00
Serhiy Storchaka eaabaac7c0
gh-89392: Use normal unittest runner in test_type_cache (GH-108911) 2023-09-05 13:46:17 +00:00
Serhiy Storchaka 420c636219
Add missed "f" in an f-string (GH-108906) 2023-09-05 12:00:28 +00:00
Mark Shannon 8b515f60ee
GH-103082: Document PEP-669: Low Impact Monitoring for CPython (GH-107772) 2023-09-05 12:35:52 +01:00
Nikita Sobolev b4c8cce9a7
gh-108840: Remove unused `TestEnumTypeSubclassing` from `test_enum` (#108841) 2023-09-05 09:45:54 +01:00
Petr Viktorin 230649f538
gh-108294: Add error handling for time.sleep audit event (GH-108363)
I've also cleaned the tests up a bit to make this easier to test.
2023-09-05 10:25:08 +02:00
Alex Waygood 24e989211a
Improve the GitHub issue forms (#108881) 2023-09-05 09:01:30 +01:00
Mark Shannon 5a2a046151
GH-108390: Prevent non-local events being set with `sys.monitoring.set_local_events()` (GH-108420) 2023-09-05 08:03:53 +01:00
Serhiy Storchaka 04a0830b00
gh-89392: Remove support of test_main() in libregrtest (GH-108876) 2023-09-05 08:36:43 +03:00
Victor Stinner 1170d5a292
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").
2023-09-05 01:09:42 +00:00
Victor Stinner 676593859e
gh-106320: Remove private _PyErr_WriteUnraisableMsg() (#108863)
Move the private _PyErr_WriteUnraisableMsg() functions to the
internal C API (pycore_pyerrors.h).

Move write_unraisable_exc() from _testcapi to _testinternalcapi.
2023-09-05 01:54:55 +02:00
Tian Gao 6304d983a0
gh-108463: Make expressions/statements work as expected in pdb (#108464) 2023-09-04 21:44:40 +00:00
Hugo van Kemenade 7855d325e6
Link to PEP sections in What's New in 3.12 (#108878) 2023-09-04 15:02:25 -06:00
Hugo van Kemenade 572678e1f8
CI: Bump GitHub Actions (#108879) 2023-09-04 22:36:16 +02:00
Nikita Sobolev 6ead5bd6ae
Disable `differing_test_runners` health check (#108886) 2023-09-04 18:31:58 +00:00
Petr Viktorin 40e52c94a2
gh-107902: Don't test setting suid/sgid on systems that don't support them (GH-108368) 2023-09-04 15:46:00 +02:00
Serhiy Storchaka f3b6608ba2
gh-89392: Fix running test_pep646_syntax as script (GH-108875) 2023-09-04 15:24:03 +03:00
Mark Shannon 5a3672cb39
GH-108614: Remove `TIER_ONE` and `TIER_TWO` from `_PUSH_FRAME` (GH-108725) 2023-09-04 11:36:57 +01:00
Serhiy Storchaka 074ac1f72e
bpo-45229: Make ElementTree tests discoverable (GH-108859) 2023-09-04 13:04:32 +03:00
Serhiy Storchaka d0b22f6bd8
gh-89392: Make test_pep646_syntax discoverable (GH-108861) 2023-09-04 12:41:58 +03:00
Serhiy Storchaka 76f3c043b6
gh-89392: Remove test_main() in test_netrc (GH-108860) 2023-09-04 12:41:13 +03:00
Victor Stinner 5a79d2ae57
Revert "gh-46376: Return existing pointer when possible in ctypes (#1… (#108688)
This reverts commit 08447b5deb.

Revert also _ctypes.c changes of the PyDict_ContainsString() change,
commit 6726626646.
2023-09-04 11:21:47 +02:00
Victor Stinner 44fc378b59
gh-108765: Move export code from pyport.h to exports.h (#108855)
There is no API change, since pyport.h includes exports.h.
2023-09-04 01:04:05 +02:00
Victor Stinner 31c2945f14
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.
2023-09-03 21:37:15 +00:00
Victor Stinner c2ec174d24
gh-108765: Move stat() fiddling from pyport.h to fileutils.h (#108854) 2023-09-03 21:32:13 +00:00
Sangyun_LEE 0c369d6cb8
Update Lib/test/test_unittest/testmock/testmock.py: fix typo RuntimError to RuntimeError (#108847) 2023-09-03 22:19:49 +01:00
Victor Stinner 03c4080c71
gh-108765: Python.h no longer includes <ctype.h> (#108831)
Remove <ctype.h> in C files which don't use it; only sre.c and
_decimal.c still use it.

Remove _PY_PORT_CTYPE_UTF8_ISSUE code from pyport.h:

* Code added by commit b5047fd019
  in 2004 for MacOSX and FreeBSD.
* Test removed by commit 52ddaefb6b
  in 2007, since Python str type now uses locale independent
  functions like Py_ISALPHA() and Py_TOLOWER() and the Unicode
  database.

Modules/_sre/sre.c replaces _PY_PORT_CTYPE_UTF8_ISSUE with new
functions: sre_isalnum(), sre_tolower(), sre_toupper().

Remove unused includes:

* _localemodule.c: remove <stdio.h>.
* getargs.c: remove <float.h>.
* dynload_win.c: remove <direct.h>, it no longer calls _getcwd()
  since commit fb1f68ed7c (in 2001).
2023-09-03 18:54:27 +02:00
Serhiy Storchaka 1796c191b4
gh-108494: Argument Clinic: inline parsing code for positional-only parameters in the limited C API (GH-108622) 2023-09-03 17:28:14 +03:00