]> git.ipfire.org Git - thirdparty/Python/cpython.git/log
thirdparty/Python/cpython.git
2 years agogh-106670: Fix Pdb handling of chained Exceptions with no stacks. (#108865)
Matthias Bussonnier [Wed, 6 Sep 2023 09:41:56 +0000 (11:41 +0200)] 
gh-106670: Fix Pdb handling of chained Exceptions with no stacks. (#108865)

2 years agoFix a typo in umarshal.py (#108803)
KH [Wed, 6 Sep 2023 09:06:41 +0000 (18:06 +0900)] 
Fix a typo in umarshal.py (#108803)

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2 years agogh-108717: Speedup `os.DirEntry.is_junction` function (#108718)
Nikita Sobolev [Wed, 6 Sep 2023 08:52:53 +0000 (11:52 +0300)] 
gh-108717: Speedup `os.DirEntry.is_junction` function (#108718)

2 years agogh-108857: improve markup in inspect.Signature.replace() docs (#108862)
nabin2004 [Wed, 6 Sep 2023 00:27:59 +0000 (06:12 +0545)] 
gh-108857: improve markup in inspect.Signature.replace() docs (#108862)

2 years agogh-108962: Skip test_tempfile.test_flags() if not supported (#108964)
Victor Stinner [Tue, 5 Sep 2023 21:59:40 +0000 (23:59 +0200)] 
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).

2 years agogh-106581: Support multiple uops pushing new values (#108895)
Guido van Rossum [Tue, 5 Sep 2023 20:58:39 +0000 (13:58 -0700)] 
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().

2 years agogh-108469: Update ast.unparse for unescaped quote support from PEP701 [3.12] (#108553)
Anthony Shaw [Tue, 5 Sep 2023 20:01:23 +0000 (06:01 +1000)] 
gh-108469: Update ast.unparse for unescaped quote support from PEP701 [3.12] (#108553)

Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
2 years agogh-107755: Document the correct default value of slice step (GH-107756)
wim glenn [Tue, 5 Sep 2023 19:22:27 +0000 (14:22 -0500)] 
gh-107755: Document the correct default value of slice step (GH-107756)

Document the correct default value of slice step.

2 years agogh-108927: Fix test_import + test_importlib + test_unittest problem (#108929)
Nikita Sobolev [Tue, 5 Sep 2023 18:57:48 +0000 (21:57 +0300)] 
gh-108927: Fix test_import + test_importlib + test_unittest problem (#108929)

2 years agogh-107565: Update Windows build to use OpenSSL 3.0.10 (GH-108928)
Zachary Ware [Tue, 5 Sep 2023 16:03:06 +0000 (11:03 -0500)] 
gh-107565: Update Windows build to use OpenSSL 3.0.10 (GH-108928)

Also clean up some intermediate NEWS entries about previous versions.

2 years agogh-108903: Remove unneeded `lambda`s from `asyncio` (GH-108904)
Nikita Sobolev [Tue, 5 Sep 2023 15:11:12 +0000 (18:11 +0300)] 
gh-108903: Remove unneeded `lambda`s from `asyncio` (GH-108904)

2 years agogh-108416: Mark slow but not CPU bound test methods with requires_resource('walltime...
Serhiy Storchaka [Tue, 5 Sep 2023 14:56:30 +0000 (17:56 +0300)] 
gh-108416: Mark slow but not CPU bound test methods with requires_resource('walltime') (GH-108480)

2 years agogh-89392: Use unittest test runner for doctests in test_getopt (GH-108916)
Serhiy Storchaka [Tue, 5 Sep 2023 14:35:28 +0000 (17:35 +0300)] 
gh-89392: Use unittest test runner for doctests in test_getopt (GH-108916)

2 years agogh-89392: Use normal unittest runner in test_type_cache (GH-108911)
Serhiy Storchaka [Tue, 5 Sep 2023 13:46:17 +0000 (16:46 +0300)] 
gh-89392: Use normal unittest runner in test_type_cache (GH-108911)

2 years agoAdd missed "f" in an f-string (GH-108906)
Serhiy Storchaka [Tue, 5 Sep 2023 12:00:28 +0000 (15:00 +0300)] 
Add missed "f" in an f-string (GH-108906)

2 years agoGH-103082: Document PEP-669: Low Impact Monitoring for CPython (GH-107772)
Mark Shannon [Tue, 5 Sep 2023 11:35:52 +0000 (12:35 +0100)] 
GH-103082: Document PEP-669: Low Impact Monitoring for CPython (GH-107772)

2 years agogh-108840: Remove unused `TestEnumTypeSubclassing` from `test_enum` (#108841)
Nikita Sobolev [Tue, 5 Sep 2023 08:45:54 +0000 (11:45 +0300)] 
gh-108840: Remove unused `TestEnumTypeSubclassing` from `test_enum` (#108841)

2 years agogh-108294: Add error handling for time.sleep audit event (GH-108363)
Petr Viktorin [Tue, 5 Sep 2023 08:25:08 +0000 (10:25 +0200)] 
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.

2 years agoImprove the GitHub issue forms (#108881)
Alex Waygood [Tue, 5 Sep 2023 08:01:30 +0000 (09:01 +0100)] 
Improve the GitHub issue forms (#108881)

2 years agoGH-108390: Prevent non-local events being set with `sys.monitoring.set_local_events...
Mark Shannon [Tue, 5 Sep 2023 07:03:53 +0000 (08:03 +0100)] 
GH-108390: Prevent non-local events being set with `sys.monitoring.set_local_events()` (GH-108420)

2 years agogh-89392: Remove support of test_main() in libregrtest (GH-108876)
Serhiy Storchaka [Tue, 5 Sep 2023 05:36:43 +0000 (08:36 +0300)] 
gh-89392: Remove support of test_main() in libregrtest (GH-108876)

2 years agogh-108834: regrtest --fail-rerun exits with code 5 (#108896)
Victor Stinner [Tue, 5 Sep 2023 01:09:42 +0000 (03:09 +0200)] 
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").

2 years agogh-106320: Remove private _PyErr_WriteUnraisableMsg() (#108863)
Victor Stinner [Mon, 4 Sep 2023 23:54:55 +0000 (01:54 +0200)] 
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.

2 years agogh-108463: Make expressions/statements work as expected in pdb (#108464)
Tian Gao [Mon, 4 Sep 2023 21:44:40 +0000 (14:44 -0700)] 
gh-108463: Make expressions/statements work as expected in pdb (#108464)

2 years agoLink to PEP sections in What's New in 3.12 (#108878)
Hugo van Kemenade [Mon, 4 Sep 2023 21:02:25 +0000 (15:02 -0600)] 
Link to PEP sections in What's New in 3.12 (#108878)

2 years agoCI: Bump GitHub Actions (#108879)
Hugo van Kemenade [Mon, 4 Sep 2023 20:36:16 +0000 (14:36 -0600)] 
CI: Bump GitHub Actions (#108879)

2 years agoDisable `differing_test_runners` health check (#108886)
Nikita Sobolev [Mon, 4 Sep 2023 18:31:58 +0000 (21:31 +0300)] 
Disable `differing_test_runners` health check (#108886)

2 years agogh-107902: Don't test setting suid/sgid on systems that don't support them (GH-108368)
Petr Viktorin [Mon, 4 Sep 2023 13:46:00 +0000 (15:46 +0200)] 
gh-107902: Don't test setting suid/sgid on systems that don't support them (GH-108368)

2 years agogh-89392: Fix running test_pep646_syntax as script (GH-108875)
Serhiy Storchaka [Mon, 4 Sep 2023 12:24:03 +0000 (15:24 +0300)] 
gh-89392: Fix running test_pep646_syntax as script (GH-108875)

2 years agoGH-108614: Remove `TIER_ONE` and `TIER_TWO` from `_PUSH_FRAME` (GH-108725)
Mark Shannon [Mon, 4 Sep 2023 10:36:57 +0000 (11:36 +0100)] 
GH-108614: Remove `TIER_ONE` and `TIER_TWO` from `_PUSH_FRAME` (GH-108725)

2 years agobpo-45229: Make ElementTree tests discoverable (GH-108859)
Serhiy Storchaka [Mon, 4 Sep 2023 10:04:32 +0000 (13:04 +0300)] 
bpo-45229: Make ElementTree tests discoverable (GH-108859)

2 years agogh-89392: Make test_pep646_syntax discoverable (GH-108861)
Serhiy Storchaka [Mon, 4 Sep 2023 09:41:58 +0000 (12:41 +0300)] 
gh-89392: Make test_pep646_syntax discoverable (GH-108861)

2 years agogh-89392: Remove test_main() in test_netrc (GH-108860)
Serhiy Storchaka [Mon, 4 Sep 2023 09:41:13 +0000 (12:41 +0300)] 
gh-89392: Remove test_main() in test_netrc (GH-108860)

2 years agoRevert "gh-46376: Return existing pointer when possible in ctypes (#1… (#108688)
Victor Stinner [Mon, 4 Sep 2023 09:21:47 +0000 (11:21 +0200)] 
Revert "gh-46376: Return existing pointer when possible in ctypes (#1… (#108688)

This reverts commit 08447b5deb47e2a0df87fa0a0576d300e5c909b4.

Revert also _ctypes.c changes of the PyDict_ContainsString() change,
commit 67266266469fe0e817736227f39537182534c1a5.

2 years agogh-108765: Move export code from pyport.h to exports.h (#108855)
Victor Stinner [Sun, 3 Sep 2023 23:04:05 +0000 (01:04 +0200)] 
gh-108765: Move export code from pyport.h to exports.h (#108855)

There is no API change, since pyport.h includes exports.h.

2 years agogh-108834: regrtest reruns failed tests in subprocesses (#108839)
Victor Stinner [Sun, 3 Sep 2023 21:37:15 +0000 (23:37 +0200)] 
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.

2 years agogh-108765: Move stat() fiddling from pyport.h to fileutils.h (#108854)
Victor Stinner [Sun, 3 Sep 2023 21:32:13 +0000 (23:32 +0200)] 
gh-108765: Move stat() fiddling from pyport.h to fileutils.h (#108854)

2 years agoUpdate Lib/test/test_unittest/testmock/testmock.py: fix typo RuntimError to RuntimeEr...
Sangyun_LEE [Sun, 3 Sep 2023 21:19:49 +0000 (06:19 +0900)] 
Update Lib/test/test_unittest/testmock/testmock.py: fix typo RuntimError to RuntimeError (#108847)

2 years agogh-108765: Python.h no longer includes <ctype.h> (#108831)
Victor Stinner [Sun, 3 Sep 2023 16:54:27 +0000 (18:54 +0200)] 
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 b5047fd01948ab108edcc1b3c2c901d915814cfd
  in 2004 for MacOSX and FreeBSD.
* Test removed by commit 52ddaefb6bab1a74ecffe8519c02735794ebfbe1
  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 fb1f68ed7cc1536482d1debd70a53c5442135fe2 (in 2001).

2 years agogh-108494: Argument Clinic: inline parsing code for positional-only parameters in...
Serhiy Storchaka [Sun, 3 Sep 2023 14:28:14 +0000 (17:28 +0300)] 
gh-108494: Argument Clinic: inline parsing code for positional-only parameters in the limited C API (GH-108622)

2 years agoFix duplicated words 'Be be' (GH-108815)
Виталий Дмитриев [Sun, 3 Sep 2023 13:35:13 +0000 (16:35 +0300)] 
Fix duplicated words 'Be be' (GH-108815)

2 years agoReorder some test's decorators (GH-108804)
Serhiy Storchaka [Sun, 3 Sep 2023 12:21:43 +0000 (15:21 +0300)] 
Reorder some test's decorators (GH-108804)

For example, do not demand the 'cpu' resource if the test cannot be run
due to non-working threads.

2 years agogh-102837: improve test coverage for math module (#102523)
Sergey B Kirpichev [Sun, 3 Sep 2023 08:48:47 +0000 (11:48 +0300)] 
gh-102837: improve test coverage for math module (#102523)

- input checks for math_1(L989), math_1a(L1023), math_2(L1064,L1071), hypot(L2682), log(L2307), ldexp(L2168), ceil(L1165), floor(L1236,L1239) and dist(L2587,L2588,L2628).
- drop inaccessible "if" branch (L3518) in perm_comb_small()
- improve fsum coverage for exceptional cases (L1433,L1438,L1451,L1497), ditto fmod(L2378)
- rewrite modf to fix inaccessible case(L2229), ditto for pow(L2988)

(all line numbers are wrt the main branch at 5e6661bce9)

2 years agogh-107208: Fix iter_index() recipe to not swallow exceptions (gh-108835)
Raymond Hettinger [Sun, 3 Sep 2023 03:25:13 +0000 (22:25 -0500)] 
gh-107208: Fix iter_index() recipe to not swallow exceptions (gh-108835)

gh-107208: iter_index now supports "stop" and no longer swallows ValueError

2 years agogh-108765: pystrhex: Replace stdlib.h abs() with Py_ABS() (#108830)
Victor Stinner [Sat, 2 Sep 2023 21:15:54 +0000 (23:15 +0200)] 
gh-108765: pystrhex: Replace stdlib.h abs() with Py_ABS() (#108830)

2 years agogh-108374: Add --disable-gil option to PCbuild/build.bat (#108729)
Sam Gross [Sat, 2 Sep 2023 21:13:00 +0000 (21:13 +0000)] 
gh-108374: Add --disable-gil option to PCbuild/build.bat (#108729)

This adds a `--disable-gil` option to PCbuild/build.bat. For now, all
this does is define the Py_NOGIL macro.

2 years agogh-108765: include <unistd.h> in termios.c on Solaris (#108825)
Jakub Kulík [Sat, 2 Sep 2023 18:57:47 +0000 (20:57 +0200)] 
gh-108765: include <unistd.h> in termios.c on Solaris (#108825)

2 years agogh-63760: Don't declare gethostname() on Solaris (#108817)
Victor Stinner [Sat, 2 Sep 2023 17:54:59 +0000 (19:54 +0200)] 
gh-63760: Don't declare gethostname() on Solaris (#108817)

Since 2005, Solaris defines gethostname(). socketmodule.c no longer
has to define gethostname() for Solaris.

Oracle Solaris and OpenSolaris have patches to remove the
gethostname() definition in Python:

* https://github.com/oracle/solaris-userland/blob/master/components/python/python37/patches/15-gethostname.patch
* https://github.com/OpenIndiana/oi-userland/blob/oi/hipster/components/python/python37/patches/15-gethostname.patch
* https://github.com/omniosorg/omnios-build/blob/master/build/python27/patches/24-gethostname.patch

Co-authored-by: Jakub Kulík <Kulikjak@gmail.com>
2 years agogh-108765: multiprocessing.h includes <unistd.h> (#108823)
Victor Stinner [Sat, 2 Sep 2023 17:54:39 +0000 (19:54 +0200)] 
gh-108765: multiprocessing.h includes <unistd.h> (#108823)

2 years agogh-108822: Add Changelog entry for regrtest statistics (#108821)
Victor Stinner [Sat, 2 Sep 2023 17:26:20 +0000 (19:26 +0200)] 
gh-108822: Add Changelog entry for regrtest statistics (#108821)

2 years agoregrtest computes statistics (#108793)
Victor Stinner [Sat, 2 Sep 2023 16:09:36 +0000 (18:09 +0200)] 
regrtest computes statistics (#108793)

test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.

Changes:

* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
  in-place.
* libregrtest summary lists the number of run tests and skipped
  tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
  test state.

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2 years agogh-108765: Python.h no longer includes <sys/time.h> (#108775)
Victor Stinner [Sat, 2 Sep 2023 15:51:19 +0000 (17:51 +0200)] 
gh-108765: Python.h no longer includes <sys/time.h> (#108775)

Python.h no longer includes <time.h>, <sys/select.h> and <sys/time.h>
standard header files.

* Add <time.h> include to xxsubtype.c.
* Add <sys/time.h> include to posixmodule.c and semaphore.c.
* readline.c includes <sys/select.h> instead of <sys/time.h>.
* resource.c no longer includes <time.h> and <sys/time.h>.

2 years agoGH-78722: Raise exceptions from `pathlib.Path.iterdir()` without delay. (#107320)
Barney Gale [Sat, 2 Sep 2023 15:08:03 +0000 (16:08 +0100)] 
GH-78722: Raise exceptions from `pathlib.Path.iterdir()` without delay. (#107320)

`pathlib.Path.iterdir()` now immediately raises any `OSError`
exception from `os.listdir()`, rather than waiting until its
result is iterated over.

2 years agogh-108765: Python.h no longer includes <unistd.h> (#108783)
Victor Stinner [Sat, 2 Sep 2023 14:50:18 +0000 (16:50 +0200)] 
gh-108765: Python.h no longer includes <unistd.h> (#108783)

2 years agogh-108794: doctest counts skipped tests (#108795)
Victor Stinner [Sat, 2 Sep 2023 14:42:07 +0000 (16:42 +0200)] 
gh-108794: doctest counts skipped tests (#108795)

* Add 'skipped' attribute to TestResults.
* Add 'skips' attribute to DocTestRunner.
* Rename private DocTestRunner._name2ft attribute
  to DocTestRunner._stats.
* Use f-string for string formatting.
* Add some tests.
* Document DocTestRunner attributes and its API for statistics.
* Document TestResults class.

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2 years agogh-108765: Python.h no longer includes <ieeefp.h> (#108781)
Victor Stinner [Sat, 2 Sep 2023 13:48:32 +0000 (15:48 +0200)] 
gh-108765: Python.h no longer includes <ieeefp.h> (#108781)

Remove also the HAVE_IEEEFP_H macro: remove ieeefp.h from the
AC_CHECK_HEADERS() check of configure.ac.

2 years agogh-108765: Remove old prototypes from pyport.h (#108782)
Victor Stinner [Sat, 2 Sep 2023 13:46:43 +0000 (15:46 +0200)] 
gh-108765: Remove old prototypes from pyport.h (#108782)

Move prototypes of gethostname(), _getpty() and struct termios from
pyport.h to the C code using them: posixmodule.c, socketmodule.c and
termios.c.

Replace "#ifdef SOLARIS" with "#ifdef __sun".

2 years agogh-101100: Fix sphinx warnings in `unittest.mock-examples.rst` (#108810)
Nikita Sobolev [Sat, 2 Sep 2023 12:05:44 +0000 (15:05 +0300)] 
gh-101100: Fix sphinx warnings in `unittest.mock-examples.rst` (#108810)

2 years agoFix typo in `uuid.rst` (#108809)
Nikita Sobolev [Sat, 2 Sep 2023 10:08:46 +0000 (13:08 +0300)] 
Fix typo in `uuid.rst` (#108809)

2 years agogh-101100: Fix sphinx warnings in `uuid.rst` (#108805)
Nikita Sobolev [Sat, 2 Sep 2023 09:32:19 +0000 (12:32 +0300)] 
gh-101100: Fix sphinx warnings in `uuid.rst` (#108805)

* gh-101100: Fix sphinx warnings in `uuid.rst`

* Use anchors

2 years agogh-108416: Mark slow test methods with @requires_resource('cpu') (GH-108421)
Serhiy Storchaka [Sat, 2 Sep 2023 04:45:34 +0000 (07:45 +0300)] 
gh-108416: Mark slow test methods with @requires_resource('cpu') (GH-108421)

Only mark tests which spend significant system or user time,
by itself or in subprocesses.

2 years agogh-108777: Split _PyTime tests from _testinternalcapi.c (gh-108787)
Sam Gross [Sat, 2 Sep 2023 00:46:36 +0000 (00:46 +0000)] 
gh-108777: Split _PyTime tests from _testinternalcapi.c (gh-108787)

2 years agoFix test_regrtest when run with uops always on (#108778)
Guido van Rossum [Fri, 1 Sep 2023 23:27:09 +0000 (16:27 -0700)] 
Fix test_regrtest when run with uops always on (#108778)

The fix has two parts:
- When `-X uops` is detected, pass it on to the subprocess created to run the manufactured test.
  I need this so I can run `./python -Xuops -m test test_regrtest` and see it fail without the next fix.
- Use `-R 6:3:` in `ArgsTestCase.test_huntrleaks` instead of `-R 3:3:` -- it takes longer to settle with `-X uops`.

2 years agogh-106392: Fix inconsistency in deprecation warnings (#106436)
William Andrea [Fri, 1 Sep 2023 22:31:21 +0000 (18:31 -0400)] 
gh-106392: Fix inconsistency in deprecation warnings (#106436)

They used "datetime" to refer to both the object and the module.

2 years agogh-107862: Add roundtrip `hypothesis` tests to `test_binascii` (#107863)
Nikita Sobolev [Fri, 1 Sep 2023 21:04:07 +0000 (00:04 +0300)] 
gh-107862: Add roundtrip `hypothesis` tests to `test_binascii` (#107863)

2 years agogh-105509: Simplify implementation of `typing.Annotated` (#105510)
Alex Waygood [Fri, 1 Sep 2023 20:57:25 +0000 (21:57 +0100)] 
gh-105509: Simplify implementation of `typing.Annotated` (#105510)

2 years agogh-105563: reference DateType in datetime's documentation (#105946)
TATHAGATA ROY [Fri, 1 Sep 2023 20:36:24 +0000 (02:06 +0530)] 
gh-105563: reference DateType in datetime's documentation (#105946)

2 years agoImprove some C API documentation (GH-108768)
Serhiy Storchaka [Fri, 1 Sep 2023 19:21:39 +0000 (22:21 +0300)] 
Improve some C API documentation (GH-108768)

* Express functions which take argument as a C string in terms of
  functions which take Python object.
* Use "note" directive for PyMapping_HasKey() and
  PyMapping_HasKeyString() notes.

2 years agogh-108765: Move standard includes to Python.h (#108769)
Victor Stinner [Fri, 1 Sep 2023 19:03:20 +0000 (21:03 +0200)] 
gh-108765: Move standard includes to Python.h (#108769)

* Move <ctype.h>, <limits.h> and <stdarg.h> standard includes to
  Python.h.
* Move "pystats.h" include from object.h to Python.h.
* Remove redundant "pymem.h" include in objimpl.h and "pyport.h"
  include in pymem.h; Python.h already includes them earlier.
* Remove redundant <wchar.h> include in unicodeobject.h; Python.h
  already includes it.
* Move _SGI_MP_SOURCE define from Python.h to pyport.h.
* pycore_condvar.h includes explicitly <unistd.h> for the
  _POSIX_THREADS macro.

2 years agoAdd Modules/_testcapi/util.h header (GH-108774)
Serhiy Storchaka [Fri, 1 Sep 2023 18:42:42 +0000 (21:42 +0300)] 
Add Modules/_testcapi/util.h header (GH-108774)

It contains common macros used in C API tests.

2 years agogh-108767: Replace ctype.h functions with pyctype.h functions (#108772)
Victor Stinner [Fri, 1 Sep 2023 16:36:53 +0000 (18:36 +0200)] 
gh-108767: Replace ctype.h functions with pyctype.h functions (#108772)

Replace <ctype.h> locale dependent functions with Python "pyctype.h"
locale independent functions:

* Replace isalpha() with Py_ISALPHA().
* Replace isdigit() with Py_ISDIGIT().
* Replace isxdigit() with Py_ISXDIGIT().
* Replace tolower() with Py_TOLOWER().

Leave Modules/_sre/sre.c unchanged, it uses locale dependent
functions on purpose.

Include explicitly <ctype.h> in _decimal.c to get isascii().

2 years agogh-108765: Reformat Include/pymacconfig.h (#108764)
Victor Stinner [Fri, 1 Sep 2023 14:57:28 +0000 (16:57 +0200)] 
gh-108765: Reformat Include/pymacconfig.h (#108764)

Replace "MacOSX" with "macOS".

2 years agogh-108765: Reformat Include/osdefs.h (#108766)
Victor Stinner [Fri, 1 Sep 2023 14:35:39 +0000 (16:35 +0200)] 
gh-108765: Reformat Include/osdefs.h (#108766)

2 years agoMake test_fcntl quiet (#108758)
Victor Stinner [Fri, 1 Sep 2023 12:59:09 +0000 (14:59 +0200)] 
Make test_fcntl quiet (#108758)

Running test_fcntl logs two "struct.pack: ..." lines because
multiprocessing imports test_fcntl twice with
test.support.verbose=1. Move get_lockdata() inside TestFcntl test
case and only call it where it's needed, to stop logging these lines.

2 years agogh-101100: Fix sphinx warnings in `tutorial/appendix.rst` (#108750)
Nikita Sobolev [Fri, 1 Sep 2023 10:57:34 +0000 (13:57 +0300)] 
gh-101100: Fix sphinx warnings in `tutorial/appendix.rst` (#108750)

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2 years agogh-101100: Fix sphinx warnings in `tutorial/classes.rst` (#108746)
Nikita Sobolev [Fri, 1 Sep 2023 10:44:43 +0000 (13:44 +0300)] 
gh-101100: Fix sphinx warnings in `tutorial/classes.rst` (#108746)

2 years agogh-108634: PyInterpreterState_New() no longer calls Py_FatalError() (#108748)
Victor Stinner [Fri, 1 Sep 2023 10:43:30 +0000 (12:43 +0200)] 
gh-108634: PyInterpreterState_New() no longer calls Py_FatalError() (#108748)

pycore_create_interpreter() now returns a status, rather than
calling Py_FatalError().

* PyInterpreterState_New() now calls Py_ExitStatusException() instead
  of calling Py_FatalError() directly.
* Replace Py_FatalError() with PyStatus in init_interpreter() and
  _PyObject_InitState().
* _PyErr_SetFromPyStatus() now raises RuntimeError, instead of
  ValueError. It can now call PyErr_NoMemory(), raise MemoryError,
  if it detects _PyStatus_NO_MEMORY() error message.

2 years agogh-108727: Fix segfault due to missing tp_dealloc definition for CounterOptimizer_Typ...
Irit Katriel [Fri, 1 Sep 2023 09:16:09 +0000 (10:16 +0100)] 
gh-108727: Fix segfault due to missing tp_dealloc definition for CounterOptimizer_Type (GH-108734)

2 years agogh-107805: Fix signatures of module-level generated functions in `turtle` (#107807)
Nikita Sobolev [Fri, 1 Sep 2023 08:18:15 +0000 (11:18 +0300)] 
gh-107805: Fix signatures of module-level generated functions in `turtle` (#107807)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2 years agogh-106320: Remove private _PyLong_Sign() (#108743)
Victor Stinner [Fri, 1 Sep 2023 07:13:07 +0000 (09:13 +0200)] 
gh-106320: Remove private _PyLong_Sign() (#108743)

Move the private _PyLong_Sign() and _PyLong_NumBits() functions
to the internal C API (pycore_long.h).

Modules/_testcapi/long.c now uses the internal C API.

2 years ago`ast` docs: Fix incorrect link on `keyword` (#108728)
Alex Povel [Thu, 31 Aug 2023 22:17:32 +0000 (00:17 +0200)] 
`ast` docs: Fix incorrect link on `keyword` (#108728)

In two places, Sphinx was erroneously adding links to the `keyword` module instead of the `ast.keyword` class

2 years agogh-107603: Argument Clinic: Only include pycore_gc.h if needed (#108726)
Victor Stinner [Thu, 31 Aug 2023 21:42:34 +0000 (23:42 +0200)] 
gh-107603: Argument Clinic: Only include pycore_gc.h if needed (#108726)

Argument Clinic now only includes pycore_gc.h if PyGC_Head is needed,
and only includes pycore_runtime.h if _Py_ID() is needed.

* Add 'condition' optional argument to Clinic.add_include().
* deprecate_keyword_use() includes pycore_runtime.h when using
  the _PyID() function.
* Fix rendering of includes: comments start at the column 35.
* Mark PC/clinic/_wmimodule.cpp.h and
  "Objects/stringlib/clinic/*.h.h" header files as generated in
  .gitattributes.

Effects:

* 42 header files generated by AC no longer include the internal C
  API, instead of 4 header files before. For example,
  Modules/clinic/_abc.c.h no longer includes the internal C API.
* Fix _testclinic_depr.c.h: it now always includes pycore_runtime.h
  to get _Py_ID().

2 years agogh-108337: Add pyatomic.h header (#108701)
Victor Stinner [Thu, 31 Aug 2023 21:41:18 +0000 (23:41 +0200)] 
gh-108337: Add pyatomic.h header (#108701)

This adds a new header that provides atomic operations on common data
types. The intention is that this will be exposed through Python.h,
although that is not the case yet. The only immediate use is in
the test file.

Co-authored-by: Sam Gross <colesbury@gmail.com>
2 years agogh-108638: Fix tests when _stat extension is missing (#108689)
Victor Stinner [Thu, 31 Aug 2023 21:14:23 +0000 (23:14 +0200)] 
gh-108638: Fix tests when _stat extension is missing (#108689)

Fix test_inspect and test_pydoc when the _stat extension is missing.
Skip tests relying on _stat when _stat is missing.

2 years agogh-108682: [Enum] raise TypeError if super().__new__ called in custom __new__ (GH...
Ethan Furman [Thu, 31 Aug 2023 19:45:12 +0000 (12:45 -0700)] 
gh-108682: [Enum] raise TypeError if super().__new__ called in custom __new__ (GH-108704)

When overriding the `__new__` method of an enum, the underlying data type should be created directly; i.e. .

    member = object.__new__(cls)
    member = int.__new__(cls, value)
    member = str.__new__(cls, value)

Calling `super().__new__()` finds the lookup version of `Enum.__new__`, and will now raise an exception when detected.

2 years agogh-108634: Py_TRACE_REFS uses a hash table (#108663)
Victor Stinner [Thu, 31 Aug 2023 16:33:34 +0000 (18:33 +0200)] 
gh-108634: Py_TRACE_REFS uses a hash table (#108663)

Python built with "configure --with-trace-refs" (tracing references)
is now ABI compatible with Python release build and debug build.
Moreover, it now also supports the Limited API.

Change Py_TRACE_REFS build:

* Remove _PyObject_EXTRA_INIT macro.
* The PyObject structure no longer has two extra members (_ob_prev
  and _ob_next).
* Use a hash table (_Py_hashtable_t) to trace references (all
  objects): PyInterpreterState.object_state.refchain.
* Py_TRACE_REFS build is now ABI compatible with release build and
  debug build.
* Limited C API extensions can now be built with Py_TRACE_REFS:
  xxlimited, xxlimited_35, _testclinic_limited.
* No longer rename PyModule_Create2() and PyModule_FromDefAndSpec2()
  functions to PyModule_Create2TraceRefs() and
  PyModule_FromDefAndSpec2TraceRefs().
* _Py_PrintReferenceAddresses() is now called before
  finalize_interp_delete() which deletes the refchain hash table.
* test_tracemalloc find_trace() now also filters by size to ignore
  the memory allocated by _PyRefchain_Trace().

Test changes for Py_TRACE_REFS:

* Add test.support.Py_TRACE_REFS constant.
* Add test_sys.test_getobjects() to test sys.getobjects() function.
* test_exceptions skips test_recursion_normalizing_with_no_memory()
  and test_memory_error_in_PyErr_PrintEx() if Python is built with
  Py_TRACE_REFS.
* test_repl skips test_no_memory().
* test_capi skisp test_set_nomemory().

2 years agogh-97850: Note in py312 whatsnew that `importlib.util.set_loader` and `importlib...
Alex Waygood [Thu, 31 Aug 2023 14:35:23 +0000 (15:35 +0100)] 
gh-97850: Note in py312 whatsnew that `importlib.util.set_loader` and `importlib.util.module_for_loader` have been removed (#108719)

Note in py312 whatsnew that `importlib.util.set_loader` and `importlib.util.module_for_loader` have been removed

2 years agogh-106320: winconsoleio.c includes pycore_pyerrors.h (#108720)
Victor Stinner [Thu, 31 Aug 2023 14:13:53 +0000 (16:13 +0200)] 
gh-106320: winconsoleio.c includes pycore_pyerrors.h (#108720)

Fix compiler warning:

    warning C4013: '_PyErr_ChainExceptions1' undefined

2 years agoRun make regen-global-objects (#108714)
Victor Stinner [Thu, 31 Aug 2023 13:37:14 +0000 (15:37 +0200)] 
Run make regen-global-objects (#108714)

2 years agogh-106320: Remove private _PyErr_ChainExceptions() (#108713)
Victor Stinner [Thu, 31 Aug 2023 11:53:19 +0000 (13:53 +0200)] 
gh-106320: Remove private _PyErr_ChainExceptions() (#108713)

Remove _PyErr_ChainExceptions(), _PyErr_ChainExceptions1() and
_PyErr_SetFromPyStatus() functions from the public C API.

* Move the private _PyErr_ChainExceptions() and
  _PyErr_ChainExceptions1() function to the internal C API
  (pycore_pyerrors.h).
* Move the private _PyErr_SetFromPyStatus() to the internal C API
  (pycore_initconfig.h).
* No longer export the _PyErr_ChainExceptions() function.
* Move run_in_subinterp_with_config() from _testcapi to
  _testinternalcapi.

2 years agoGH-108614: Remove non-debug uses of `#if TIER_ONE` and `#if TIER_TWO` from `_POP_FRAM...
Mark Shannon [Thu, 31 Aug 2023 10:34:52 +0000 (11:34 +0100)] 
GH-108614: Remove non-debug uses of `#if TIER_ONE` and `#if TIER_TWO` from `_POP_FRAME` op. (GH-108685)

2 years agogh-106320: Don't export _Py_ForgetReference() function (#108712)
Victor Stinner [Thu, 31 Aug 2023 09:15:31 +0000 (11:15 +0200)] 
gh-106320: Don't export _Py_ForgetReference() function (#108712)

There is no need to export the _Py_ForgetReference() function of the
Py_TRACE_REFS build. It's not used by shared extensions. Enhance also
its comment.

2 years agogh-107149: Make PyUnstable_ExecutableKinds public (#108440)
Victor Stinner [Thu, 31 Aug 2023 07:56:06 +0000 (09:56 +0200)] 
gh-107149: Make PyUnstable_ExecutableKinds public (#108440)

Move PyUnstable_ExecutableKinds and associated macros from the
internal C API to the public C API.

Rename constants: replace "PY_" prefix with "PyUnstable_" prefix.

2 years agogh-108455: peg_generator: use `types-setuptools==68.1.0.1` in CI (#108697)
Alex Waygood [Thu, 31 Aug 2023 07:41:25 +0000 (08:41 +0100)] 
gh-108455: peg_generator: use `types-setuptools==68.1.0.1` in CI (#108697)

2 years agogh-101100: Fix sphinx warnings in `threading.rst` (#108684)
Nikita Sobolev [Thu, 31 Aug 2023 07:28:27 +0000 (10:28 +0300)] 
gh-101100: Fix sphinx warnings in `threading.rst` (#108684)

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2 years agogh-108696: revert bypassing import cache in test_import helper (#108698)
Carl Meyer [Thu, 31 Aug 2023 00:15:31 +0000 (18:15 -0600)] 
gh-108696: revert bypassing import cache in test_import helper (#108698)

2 years agogh-108654: restore comprehension locals before handling exception (#108659)
Carl Meyer [Wed, 30 Aug 2023 23:50:50 +0000 (17:50 -0600)] 
gh-108654: restore comprehension locals before handling exception (#108659)

Co-authored-by: Dong-hee Na <donghee.na92@gmail.com>
2 years agogh-108297: Remove test_crashers (#108690)
Victor Stinner [Wed, 30 Aug 2023 19:33:04 +0000 (21:33 +0200)] 
gh-108297: Remove test_crashers (#108690)

The test was skipped in 2011 by
commit 89ba56d5fb1335ef808b87cd33cba95ea141c65d.

Scripts in Lib/test/crashers/ do not crash on a reliable way. They
rely on undefined behaviors, like state of the stack memory, and so
may or may not crash. It is not worth it to make sure that they crash
in a continious integration, they should be run manually time to time
instead.

2 years agogh-108520: Fix bad fork detection in nested multiprocessing use case (#108568)
albanD [Wed, 30 Aug 2023 17:07:41 +0000 (13:07 -0400)] 
gh-108520: Fix bad fork detection in nested multiprocessing use case (#108568)

gh-107275 introduced a regression where a SemLock would fail being passed along nested child processes, as the `is_fork_ctx` attribute would be left missing after the first deserialization.

---------

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Antoine Pitrou <pitrou@free.fr>
2 years agogh-108590: Revert gh-108657 (commit 400a1cebc) (#108686)
Erlend E. Aasland [Wed, 30 Aug 2023 14:53:10 +0000 (16:53 +0200)] 
gh-108590: Revert gh-108657 (commit 400a1cebc) (#108686)

Reverted per Serhiy's request.