]> git.ipfire.org Git - thirdparty/Python/cpython.git/log
thirdparty/Python/cpython.git
23 months agogh-111924: Use PyMutex for runtime global locks.
Sam Gross [Thu, 16 Nov 2023 21:41:21 +0000 (16:41 -0500)] 
gh-111924: Use PyMutex for runtime global locks.

This replaces some usages of PyThread_type_lock with PyMutex, which
does not require memory allocation to initialize.

23 months agogh-111800: Fix `test_recursive_repr` from `test_io` under WASI to not recurse so...
Nikita Sobolev [Thu, 16 Nov 2023 19:47:38 +0000 (22:47 +0300)] 
gh-111800: Fix `test_recursive_repr` from `test_io` under WASI to not recurse so deeply (GH-112150)

23 months agoRemove `imp_dummy_def` from `Tools/c-analyzer/cpython/ignored.tsv` (gh-112122)
Nikita Sobolev [Thu, 16 Nov 2023 19:21:23 +0000 (22:21 +0300)] 
Remove `imp_dummy_def` from `Tools/c-analyzer/cpython/ignored.tsv` (gh-112122)

It was removed in 3.12, no need to keep the ignore.

23 months agogh-111956: Add thread-safe one-time initialization. (gh-111960)
Sam Gross [Thu, 16 Nov 2023 19:19:54 +0000 (14:19 -0500)] 
gh-111956: Add thread-safe one-time initialization. (gh-111960)

23 months agogh-111881: Import lazily zipfile in support.script_helper (#112172)
Victor Stinner [Thu, 16 Nov 2023 17:57:22 +0000 (18:57 +0100)] 
gh-111881: Import lazily zipfile in support.script_helper (#112172)

It allows running the test suite when the zlib extension is missing.

23 months agogh-112155: Run `typing.py` doctests as part of `test_typing` (#112156)
Nikita Sobolev [Thu, 16 Nov 2023 15:40:09 +0000 (18:40 +0300)] 
gh-112155: Run `typing.py` doctests as part of `test_typing` (#112156)

23 months agoGH-112152: Fix typo in `typing.override` docstring (#112158)
Qua27 [Thu, 16 Nov 2023 15:16:04 +0000 (18:16 +0300)] 
GH-112152: Fix typo in `typing.override` docstring (#112158)

23 months agogh-111798: Use lower Py_C_RECURSION_LIMIT in debug mode (#112124)
Victor Stinner [Thu, 16 Nov 2023 13:52:33 +0000 (14:52 +0100)] 
gh-111798: Use lower Py_C_RECURSION_LIMIT in debug mode (#112124)

* Run again test_ast_recursion_limit() on WASI platform.
* Add _testinternalcapi.get_c_recursion_remaining().
* Fix test_ast and test_sys_settrace: test_ast_recursion_limit() and
  test_trace_unpack_long_sequence() now adjust the maximum recursion
  depth depending on the the remaining C recursion.

23 months ago[doc] Make subprocess.wait documentation more precise (#98700)
Luis Pedro Coelho [Thu, 16 Nov 2023 13:04:46 +0000 (23:04 +1000)] 
[doc] Make subprocess.wait documentation more precise (#98700)

[doc] Make subprocess.wait doc more precise

An active loop is only used when the `timeout` parameter is used on
POSIX.

When no timeout is used, the code calls `os.waitpid` internally (which puts
the process on a sleep status). On Windows, the internal Windows API
call accepts a timeout parameter, so that is delegated to the OS.

23 months agogh-110812: Isolating Extension Modules HOWTO: List GC-related gotchas (GH-111504)
Petr Viktorin [Thu, 16 Nov 2023 11:05:44 +0000 (12:05 +0100)] 
gh-110812: Isolating Extension Modules HOWTO: List GC-related gotchas (GH-111504)

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
23 months agogh-111916: Make hashlib related modules thread-safe without the GIL (#111981)
Tomas R [Wed, 15 Nov 2023 23:53:38 +0000 (00:53 +0100)] 
gh-111916: Make hashlib related modules thread-safe without the GIL (#111981)

Always use an individual lock on hash objects when in free-threaded builds.

Fixes #111916

23 months agogh-111811: Fix test_recursive_repr for WASI (#112130)
Kushal Das [Wed, 15 Nov 2023 22:28:58 +0000 (23:28 +0100)] 
gh-111811: Fix test_recursive_repr for WASI (#112130)

23 months agogh-112088: Run autoreconf in GHA check_generated_files (#112090)
Victor Stinner [Wed, 15 Nov 2023 20:47:14 +0000 (21:47 +0100)] 
gh-112088: Run autoreconf in GHA check_generated_files (#112090)

The "Check if generated files are up to date" job of GitHub Actions
now runs the "autoreconf -ivf -Werror" command instead of the "make
regen-configure" command to avoid depending on the external quay.io
server.

Add Tools/build/regen-configure.sh script to regenerate the configure
with an Ubuntu container image. The
"quay.io/tiran/cpython_autoconf:271" container image
(https://github.com/tiran/cpython_autoconf) is no longer used.

23 months agogh-112026: Add again _PyThreadState_UncheckedGet() function (#112121)
Victor Stinner [Wed, 15 Nov 2023 18:15:03 +0000 (19:15 +0100)] 
gh-112026: Add again _PyThreadState_UncheckedGet() function (#112121)

Add again the private _PyThreadState_UncheckedGet() function as an
alias to the new public PyThreadState_GetUnchecked() function.

23 months agogh-96954: Don't run regen-unicodedata in regen-all (#112120)
Victor Stinner [Wed, 15 Nov 2023 17:14:08 +0000 (18:14 +0100)] 
gh-96954: Don't run regen-unicodedata in regen-all (#112120)

The "make regen-unicodedata" should now be run manually. By the
default, it requires an Internet connection, which is not always the
case. Some Linux distributions build Linux packages in isolated
environment (without network).

23 months agogh-112026: Restore removed _PyDict_GetItemStringWithError() (#112119)
Victor Stinner [Wed, 15 Nov 2023 17:10:06 +0000 (18:10 +0100)] 
gh-112026: Restore removed _PyDict_GetItemStringWithError() (#112119)

Restore the removed _PyDict_GetItemStringWithError() function. It is
used by numpy.

23 months agogh-96954: Fix `make regen-unicodedata` in out-of-tree builds (#112118)
Miro Hrončok [Wed, 15 Nov 2023 16:42:17 +0000 (17:42 +0100)] 
gh-96954: Fix `make regen-unicodedata` in out-of-tree builds (#112118)

This avoids:

    python3.13 Tools/unicode/makeunicodedata.py
    python3.13: can't open file '.../build/debug/Tools/unicode/makeunicodedata.py': [Errno 2] No such file or directory
    make: *** [Makefile:1498: regen-unicodedata] Error 2

Re-run `make regen-unicodedata` to update the script path in generated files.

23 months agogh-112026: Restore removed private C API (#112115)
Victor Stinner [Wed, 15 Nov 2023 16:38:31 +0000 (17:38 +0100)] 
gh-112026: Restore removed private C API (#112115)

Restore removed private C API functions, macros and structures which
have no simple replacement for now:

* _PyDict_GetItem_KnownHash()
* _PyDict_NewPresized()
* _PyHASH_BITS
* _PyHASH_IMAG
* _PyHASH_INF
* _PyHASH_MODULUS
* _PyHASH_MULTIPLIER
* _PyLong_Copy()
* _PyLong_FromDigits()
* _PyLong_New()
* _PyLong_Sign()
* _PyObject_CallMethodId()
* _PyObject_CallMethodNoArgs()
* _PyObject_CallMethodOneArg()
* _PyObject_CallOneArg()
* _PyObject_EXTRA_INIT
* _PyObject_FastCallDict()
* _PyObject_GetAttrId()
* _PyObject_Vectorcall()
* _PyObject_VectorcallMethod()
* _PyStack_AsDict()
* _PyThread_CurrentFrames()
* _PyUnicodeWriter structure
* _PyUnicodeWriter_Dealloc()
* _PyUnicodeWriter_Finish()
* _PyUnicodeWriter_Init()
* _PyUnicodeWriter_Prepare()
* _PyUnicodeWriter_PrepareKind()
* _PyUnicodeWriter_WriteASCIIString()
* _PyUnicodeWriter_WriteChar()
* _PyUnicodeWriter_WriteLatin1String()
* _PyUnicodeWriter_WriteStr()
* _PyUnicodeWriter_WriteSubstring()
* _PyUnicode_AsString()
* _PyUnicode_FromId()
* _PyVectorcall_Function()
* _Py_HashDouble()
* _Py_HashPointer()
* _Py_IDENTIFIER()
* _Py_c_abs()
* _Py_c_diff()
* _Py_c_neg()
* _Py_c_pow()
* _Py_c_prod()
* _Py_c_quot()
* _Py_c_sum()
* _Py_static_string()
* _Py_static_string_init()

23 months agogh-112026: Add again <unistd.h> include in Python.h (#112046)
Victor Stinner [Wed, 15 Nov 2023 15:59:32 +0000 (16:59 +0100)] 
gh-112026: Add again <unistd.h> include in Python.h (#112046)

Add again <ctype.h> and <unistd.h> includes in Python.h, but don't
include them in the limited C API version 3.13 and newer.

23 months agoGH-111848: Set the IP when de-optimizing (GH-112065)
Mark Shannon [Wed, 15 Nov 2023 15:48:58 +0000 (15:48 +0000)] 
GH-111848: Set the IP when de-optimizing (GH-112065)

* Replace jumps with deopts in tier 2

* Fewer special cases of uop names

* Add target field to uop IR

* Remove more redundant SET_IP and _CHECK_VALIDITY micro-ops

* Extend whitelist of non-escaping API functions.

23 months agoFix typo in perf profiling docs (#112112)
Ryuji Tsutsui [Wed, 15 Nov 2023 15:40:19 +0000 (00:40 +0900)] 
Fix typo in perf profiling docs (#112112)

23 months agogh-108303: Delete `imp_dummy` test file (#112110)
Nikita Sobolev [Wed, 15 Nov 2023 12:26:49 +0000 (15:26 +0300)] 
gh-108303: Delete `imp_dummy` test file (#112110)

23 months agogh-111789: Use PyDict_GetItemRef() in Modules/_asynciomodule.c (GH-112072)
Serhiy Storchaka [Wed, 15 Nov 2023 04:28:30 +0000 (06:28 +0200)] 
gh-111789: Use PyDict_GetItemRef() in Modules/_asynciomodule.c (GH-112072)

23 months agoDocs: Add the time to the HTML last updated format (#110091)
Adam Turner [Wed, 15 Nov 2023 04:04:28 +0000 (04:04 +0000)] 
Docs: Add the time to the HTML last updated format (#110091)

23 months agogh-112062: Make `_struct` module thread-safe in `--disable-gil` builds (#112094)
Radislav Chugunov [Wed, 15 Nov 2023 04:00:34 +0000 (07:00 +0300)] 
gh-112062: Make `_struct` module thread-safe in `--disable-gil` builds (#112094)

* gh-112062: Make `_struct` module thread-safe in --disable-gil builds

23 months agogh-111545: Test PyHash_GetFuncDef() function (#112098)
Victor Stinner [Wed, 15 Nov 2023 02:41:29 +0000 (03:41 +0100)] 
gh-111545: Test PyHash_GetFuncDef() function (#112098)

Add Modules/_testcapi/hash.c and Lib/test/test_capi/test_hash.py.

23 months agogh-109538: Avoid RuntimeError when StreamWriter is deleted with closed loop (#111983)
DPR [Wed, 15 Nov 2023 01:17:51 +0000 (09:17 +0800)] 
gh-109538: Avoid RuntimeError when StreamWriter is deleted with closed loop (#111983)

Issue a ResourceWarning instead.

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
23 months agogh-111995: Add getnameinfo extension flag (#111994)
adder32 [Wed, 15 Nov 2023 01:00:24 +0000 (02:00 +0100)] 
gh-111995: Add getnameinfo extension flag (#111994)

Add getnameinfo extension NI_IDN flag.

23 months agogh-111545: Add Include/cpython/pyhash.h header file (#112063)
Victor Stinner [Wed, 15 Nov 2023 00:19:20 +0000 (01:19 +0100)] 
gh-111545: Add Include/cpython/pyhash.h header file (#112063)

Move non-limited C API to a new Include/cpython/pyhash.h header file.

23 months agogh-111942: Fix SystemError in the TextIOWrapper constructor (#112061)
Serhiy Storchaka [Tue, 14 Nov 2023 20:02:28 +0000 (22:02 +0200)] 
gh-111942: Fix SystemError in the TextIOWrapper constructor (#112061)

In non-debug more the check for the "errors" argument is skipped,
and then PyUnicode_AsUTF8() can fail, but its result was not checked.

Co-authored-by: Victor Stinner <vstinner@python.org>
23 months agogh-111906: Fix warnings during mimalloc build on FreeBSD (#111907)
Furkan Onder [Tue, 14 Nov 2023 16:07:46 +0000 (19:07 +0300)] 
gh-111906: Fix warnings during mimalloc build on FreeBSD (#111907)

Fix `unused function` warnings during mimalloc build on FreeBSD.

23 months agogh-111942: Fix crashes in TextIOWrapper.reconfigure() (GH-111976)
Serhiy Storchaka [Tue, 14 Nov 2023 15:37:56 +0000 (17:37 +0200)] 
gh-111942: Fix crashes in TextIOWrapper.reconfigure() (GH-111976)

* Fix crash when encoding is not string or None.
* Fix crash when both line_buffering and write_through raise exception
  when converted ti int.
* Add a number of tests for constructor and reconfigure() method
  with invalid arguments.

23 months agoGH-111848: Convert remaining jumps to deopts into tier 2 code. (GH-112045)
Mark Shannon [Tue, 14 Nov 2023 15:30:33 +0000 (15:30 +0000)] 
GH-111848: Convert remaining jumps to deopts into tier 2 code. (GH-112045)

23 months agogh-111789: Simplify bytecodes.c by using PyDict_GetItemRef() (GH-111978)
Serhiy Storchaka [Tue, 14 Nov 2023 13:38:49 +0000 (15:38 +0200)] 
gh-111789: Simplify bytecodes.c by using PyDict_GetItemRef() (GH-111978)

23 months agogh-111262: Add PyDict_Pop() function (#112028)
Victor Stinner [Tue, 14 Nov 2023 12:51:00 +0000 (13:51 +0100)] 
gh-111262: Add PyDict_Pop() function (#112028)

_PyDict_Pop_KnownHash(): remove the default value and the return type
becomes an int.

Co-authored-by: Stefan Behnel <stefan_ml@behnel.de>
Co-authored-by: Antoine Pitrou <pitrou@free.fr>
23 months agogh-110944: Make pdb completion work for alias and convenience vars (GH-110945)
Tian Gao [Tue, 14 Nov 2023 12:22:25 +0000 (04:22 -0800)] 
gh-110944: Make pdb completion work for alias and convenience vars (GH-110945)

23 months agogh-111903: Add `@critical_section` directive to Argument Clinic. (#111904)
Sam Gross [Tue, 14 Nov 2023 10:47:46 +0000 (05:47 -0500)] 
gh-111903: Add `@critical_section` directive to Argument Clinic. (#111904)

The `@critical_section` directive instructs Argument Clinic to generate calls
to `Py_BEGIN_CRITICAL_SECTION()` and `Py_END_CRITICAL_SECTION()` around the
bound function. In `--disable-gil` builds, these calls will lock and unlock
the `self` object. They are no-ops in the default build.

This is used in one place (`_io._Buffered.close`) as a demonstration.
Subsequent PRs will use it more widely in the `_io.Buffered` bindings.

23 months agogh-111789: Simplify ceval.c by using PyDict_GetItemRef() (GH-111980)
Serhiy Storchaka [Tue, 14 Nov 2023 09:29:49 +0000 (11:29 +0200)] 
gh-111789: Simplify ceval.c by using PyDict_GetItemRef() (GH-111980)

23 months agogh-111789: Simplify import.c by using PyDict_GetItemRef() (GH-111979)
Serhiy Storchaka [Tue, 14 Nov 2023 09:29:20 +0000 (11:29 +0200)] 
gh-111789: Simplify import.c by using PyDict_GetItemRef() (GH-111979)

23 months agogh-111789: Use PyDict_GetItemRef() in _ctypes (GH-111828)
Serhiy Storchaka [Tue, 14 Nov 2023 09:28:34 +0000 (11:28 +0200)] 
gh-111789: Use PyDict_GetItemRef() in _ctypes (GH-111828)

23 months agogh-111789: Use PyDict_GetItemRef() in Objects/ (GH-111827)
Serhiy Storchaka [Tue, 14 Nov 2023 09:25:39 +0000 (11:25 +0200)] 
gh-111789: Use PyDict_GetItemRef() in Objects/ (GH-111827)

23 months agogh-111622: Fix doc for items views (#112051)
Terry Jan Reedy [Tue, 14 Nov 2023 07:41:20 +0000 (02:41 -0500)] 
gh-111622: Fix doc for items views (#112051)

They are set-like even when some values are not hashable,
but work even better when all are.

23 months agoGH-111520: Add back the operand local (GH-111813)
Brandt Bucher [Tue, 14 Nov 2023 01:27:19 +0000 (17:27 -0800)] 
GH-111520: Add back the operand local (GH-111813)

23 months agogh-107149: make new opcode util functions private rather than public and unstable...
Irit Katriel [Tue, 14 Nov 2023 00:31:02 +0000 (00:31 +0000)] 
gh-107149: make new opcode util functions private rather than public and unstable (#112042)

23 months agogh-112007: Re-organize help utility intro message (#112017)
Terry Jan Reedy [Mon, 13 Nov 2023 19:24:03 +0000 (14:24 -0500)] 
gh-112007: Re-organize help utility intro message (#112017)

Most important: move how-to-quit sentence to the end and mention 'q'.
Re-group the other sentences and improve some wording.
---------
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
23 months agoGH-110417: Fix `glob` docs ordering (#110418)
Barney Gale [Mon, 13 Nov 2023 17:48:16 +0000 (17:48 +0000)] 
GH-110417: Fix `glob` docs ordering (#110418)

Fix incorrect placement of `translate()` docs from cf67ebf.

Move "see also: pathlib" admonition to the bottom of the page, alongside one for fnmatch. This helps the module introduction flow more naturally into the function descriptions.

Add an "Examples" subheading just before the examples. This makes it more obvious that examples aren't specifically related to the preceding documentation of `escape()` and `translate()`.

23 months agoGH-72904: Add `glob.translate()` function (#106703)
Barney Gale [Mon, 13 Nov 2023 17:15:56 +0000 (17:15 +0000)] 
GH-72904: Add `glob.translate()` function (#106703)

Add `glob.translate()` function that converts a pathname with shell wildcards to a regular expression. The regular expression is used by pathlib to implement `match()` and `glob()`.

This function differs from `fnmatch.translate()` in that wildcards do not match path separators by default, and that a `*` pattern segment matches precisely one path segment. When *recursive* is set to true, `**` pattern segments match any number of path segments, and `**` cannot appear outside its own segment.

In pathlib, this change speeds up directory walking (because `_make_child_relpath()` does less work), makes path objects smaller (they don't need a `_lines` slot), and removes the need for some gnarly code.

Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
23 months agogh-111138: Add PyList_Extend() and PyList_Clear() functions (#111862)
Victor Stinner [Mon, 13 Nov 2023 16:14:56 +0000 (17:14 +0100)] 
gh-111138: Add PyList_Extend() and PyList_Clear() functions (#111862)

* Split list_extend() into two sub-functions: list_extend_fast() and
  list_extend_iter().
* list_inplace_concat() no longer has to call Py_DECREF() on the
  list_extend() result, since list_extend() now returns an int.

23 months agogh-111856: Fix os.fstat on windows with FAT32 and exFAT filesystem (GH-112038)
AN Long [Mon, 13 Nov 2023 16:10:06 +0000 (00:10 +0800)] 
gh-111856: Fix os.fstat on windows with FAT32 and exFAT filesystem (GH-112038)

23 months agogh-111460: Restore ncurses widechar support on macOS (#111878)
Davide Rizzo [Mon, 13 Nov 2023 13:36:50 +0000 (14:36 +0100)] 
gh-111460: Restore ncurses widechar support on macOS (#111878)

23 months agogh-106905: avoid incorrect SystemError about recursion depth mismatch (#106906)
Markus Mohrhard [Mon, 13 Nov 2023 13:05:17 +0000 (21:05 +0800)] 
gh-106905: avoid incorrect SystemError about recursion depth mismatch (#106906)

* gh-106905: avoid incorrect SystemError about recursion depth mismatch

* Update Misc/NEWS.d/next/Core and Builtins/2023-07-20-11-41-16.gh-issue-106905.AyZpuB.rst

---------

Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
23 months agogh-110944: Move pty helper to test.support and add basic pdb completion test (GH...
Tian Gao [Mon, 13 Nov 2023 10:23:06 +0000 (02:23 -0800)] 
gh-110944: Move pty helper to test.support and add basic pdb completion test (GH-111826)

23 months agogh-102837: more tests for the math module (GH-111930)
Sergey B Kirpichev [Mon, 13 Nov 2023 09:57:57 +0000 (12:57 +0300)] 
gh-102837: more tests for the math module (GH-111930)

Add tests to improve coverage:

* fsum: L1369, L1379, L1383, L1412
* trunc: L2081
* log: L2267
* dist: L2577, L2579
* hypot: L2632
* sumprod: L2744, L2754, L2774, L2778, L2781, L2785, L2831, L2835, L2838
* pow: L2982
* prod: L3294, L3308, L3318-3330

// line numbers wrt to 9dc4fb8204

23 months agoDocs: Add `make htmllive` to rebuild and reload HTML files in your browser (#111900)
Hugo van Kemenade [Mon, 13 Nov 2023 08:06:49 +0000 (10:06 +0200)] 
Docs: Add `make htmllive` to rebuild and reload HTML files in your browser (#111900)

23 months agogh-111999: Add signatures and improve docstrings for builtins (GH-112000)
Serhiy Storchaka [Mon, 13 Nov 2023 07:13:49 +0000 (09:13 +0200)] 
gh-111999: Add signatures and improve docstrings for builtins (GH-112000)

23 months agogh-111928: make "memo" dict local to scan_once call (gh-112005)
AN Long [Mon, 13 Nov 2023 04:58:34 +0000 (12:58 +0800)] 
gh-111928: make "memo" dict local to scan_once call (gh-112005)

Co-authored-by: Sam Gross <colesbury@gmail.com>
23 months agogh-111944: Add assignment expression parentheses requirements (#111977)
Terry Jan Reedy [Mon, 13 Nov 2023 00:06:50 +0000 (19:06 -0500)] 
gh-111944: Add assignment expression parentheses requirements (#111977)

gh-111944: Clarify where assignment expressions require ()s

Augment the list of places where parentheses are
required around assignnment statements.  In particular,
'a := 0' and 'a = b := 1' are syntax errors.

23 months agoGH-111429: Speed up `pathlib.PurePath.[is_]relative_to()` (#111431)
Barney Gale [Sun, 12 Nov 2023 22:59:17 +0000 (22:59 +0000)] 
GH-111429: Speed up `pathlib.PurePath.[is_]relative_to()` (#111431)

23 months agogh-111969: refactor to make it easier to construct a dis.Instruction object (#111970)
Irit Katriel [Sun, 12 Nov 2023 14:06:02 +0000 (14:06 +0000)] 
gh-111969: refactor to make it easier to construct a dis.Instruction object (#111970)

23 months agogh-112001: Fix test_builtins_have_signatures in test_inspect (GH-112002)
Serhiy Storchaka [Sun, 12 Nov 2023 11:35:31 +0000 (13:35 +0200)] 
gh-112001: Fix test_builtins_have_signatures in test_inspect (GH-112002)

23 months agogh-111933: fix broken link to A.Neumaier article (gh-111937)
Sergey B Kirpichev [Sun, 12 Nov 2023 00:53:41 +0000 (03:53 +0300)] 
gh-111933: fix broken link to A.Neumaier article (gh-111937)

23 months agogh-111777: Fix assertion errors on incorrectly still-tracked GC object destruction...
T. Wouters [Sun, 12 Nov 2023 00:03:34 +0000 (01:03 +0100)] 
gh-111777: Fix assertion errors on incorrectly still-tracked GC object destruction (#111778)

In PyObject_GC_Del, in Py_DEBUG mode, when warning about GC objects that
were not properly untracked before starting destruction, take care to
untrack the object _before_ warning, to avoid triggering a GC run and
causing the problem the code tries to warn about. Also make sure to save and
restore any pending exceptions, which the warning would otherwise clobber or
trigger an assertion error on.

23 months agoFix undefined behaviour in datetime.time.fromisoformat() (#111982)
T. Wouters [Sat, 11 Nov 2023 23:56:27 +0000 (00:56 +0100)] 
Fix undefined behaviour in datetime.time.fromisoformat() (#111982)

Fix undefined behaviour in datetime.time.fromisoformat() when parsing a string without a timezone. 'tzoffset' is not assigned to by parse_isoformat_time if it returns 0, but time_fromisoformat then passes tzoffset to another function, which is undefined behaviour (even if the function in question does not use the value).

23 months agogh-90890: New methods to access mailbox.Maildir message info and flags (#103905)
Stephen Gildea [Sat, 11 Nov 2023 17:41:33 +0000 (09:41 -0800)] 
gh-90890: New methods to access mailbox.Maildir message info and flags (#103905)

New methods to access mailbox.Maildir message info and flags:
get_info, set_info, get_flags, set_flags, add_flag, remove_flag.

These methods speed up accessing a message's info and/or flags and are
useful when it is not necessary to access the message's contents,
as when iterating over a Maildir to find messages with specific flags.

---------

* Add more str type checking
* modernize to f-strings instead of %

Co-authored-by: Gregory P. Smith <greg@krypto.org>
23 months agogh-110481: fix 'unused function' warning for `is_shared_refcnt_dead`. (gh-111974)
Sam Gross [Fri, 10 Nov 2023 23:54:35 +0000 (18:54 -0500)] 
gh-110481: fix 'unused function' warning for `is_shared_refcnt_dead`. (gh-111974)

Fix 'unused function' warning for `is_shared_refcnt_dead`.

The `is_shared_refcnt_dead` function is only used if `Py_REF_DEBUG` is set.

23 months agogh-107431: Make `multiprocessing.managers.{DictProxy,ListProxy}` generic (#107433)
Nikita Sobolev [Fri, 10 Nov 2023 23:23:27 +0000 (02:23 +0300)] 
gh-107431: Make `multiprocessing.managers.{DictProxy,ListProxy}` generic (#107433)

Make `multiprocessing.managers.{DictProxy,ListProxy}` generic for type annotation use.  `ListProxy[str]` for example.

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
23 months agoRemove dead code left after gh-110721 (#111905)
Serhiy Storchaka [Fri, 10 Nov 2023 22:30:01 +0000 (00:30 +0200)] 
Remove dead code left after gh-110721 (#111905)

23 months agogh-80731: Avoid executing code in except block in cmd (GH-111740)
Tian Gao [Fri, 10 Nov 2023 21:13:29 +0000 (13:13 -0800)] 
gh-80731: Avoid executing code in except block in cmd (GH-111740)

23 months agogh-111789: Simplify the sqlite code (GH-111829)
Serhiy Storchaka [Fri, 10 Nov 2023 20:49:24 +0000 (22:49 +0200)] 
gh-111789: Simplify the sqlite code (GH-111829)

Use new C API functions PyDict_GetItemRef() and
PyMapping_GetOptionalItemString().

23 months agoAdd private _PyUnicode_AsUTF8NoNUL() function (GH-111957)
Serhiy Storchaka [Fri, 10 Nov 2023 19:31:36 +0000 (21:31 +0200)] 
Add private _PyUnicode_AsUTF8NoNUL() function (GH-111957)

Like PyUnicode_AsUTF8(), but check for embedded null characters.

23 months agogh-110722: Make `-m test -T -j` use sys.monitoring (GH-111710)
Łukasz Langa [Fri, 10 Nov 2023 17:17:45 +0000 (18:17 +0100)] 
gh-110722: Make `-m test -T -j` use sys.monitoring (GH-111710)

Now all results from worker processes are aggregated and
displayed together as a summary at the end of a regrtest run.

The traditional trace is left in place for use with sequential
in-process test runs but now raises a warning that those
numbers are not precise.

`-T -j` requires `--with-pydebug` as it relies on `-Xpresite=`.

23 months agogh-111841: Fix os.putenv() and os.unsetenv() with embedded NUL on Windows (GH-111842)
Serhiy Storchaka [Fri, 10 Nov 2023 16:42:14 +0000 (18:42 +0200)] 
gh-111841: Fix os.putenv() and os.unsetenv() with embedded NUL on Windows (GH-111842)

23 months agoBump mypy to 1.7.0 (#111961)
Alex Waygood [Fri, 10 Nov 2023 16:00:50 +0000 (16:00 +0000)] 
Bump mypy to 1.7.0 (#111961)

23 months agogh-103791: handle `BaseExceptionGroup` in `contextlib.suppress()` (#111910)
Zac Hatfield-Dodds [Fri, 10 Nov 2023 13:32:36 +0000 (08:32 -0500)] 
gh-103791: handle `BaseExceptionGroup` in `contextlib.suppress()` (#111910)

23 months agogh-111912: Run test_posix on Windows (GH-111913)
Serhiy Storchaka [Fri, 10 Nov 2023 13:29:15 +0000 (15:29 +0200)] 
gh-111912: Run test_posix on Windows (GH-111913)

23 months agogh-108303: Install `Lib/test/configdata` (#111899)
Nikita Sobolev [Fri, 10 Nov 2023 12:00:50 +0000 (15:00 +0300)] 
gh-108303: Install `Lib/test/configdata` (#111899)

23 months agogh-111356: io: Add missing documented objects to io.__all__ (#111370)
Nicolas Tessore [Fri, 10 Nov 2023 07:18:52 +0000 (07:18 +0000)] 
gh-111356: io: Add missing documented objects to io.__all__ (#111370)

Add DEFAULT_BUFFER_SIZE, text_encoding, and IncrementalNewlineDecoder.

23 months agogh-111569: Fix critical sections test on WebAssembly (GH-111897)
Sam Gross [Thu, 9 Nov 2023 23:37:11 +0000 (18:37 -0500)] 
gh-111569: Fix critical sections test on WebAssembly (GH-111897)

This adds a macro `Py_CAN_START_THREADS` that corresponds to the Python
function `test.support.threading_helper.can_start_thread()`. WASI and
some Emscripten builds do not have a working pthread implementation.

This macro is used to guard the critical sections C API tests that
require a working threads implementation.

23 months agogh-111881: Import _sha2 lazily in random (#111889)
Victor Stinner [Thu, 9 Nov 2023 22:10:21 +0000 (23:10 +0100)] 
gh-111881: Import _sha2 lazily in random (#111889)

The random module now imports the _sha2 module lazily in the
Random.seed() method for str, bytes and bytearray seeds. It also
imports lazily the warnings module in the _randbelow() method for
classes without getrandbits(). Lazy import makes Python startup
faster and reduces the number of imported modules at startup.

23 months agogh-81925: Implement native thread ids for kFreeBSD (#111761)
Samuel Thibault [Thu, 9 Nov 2023 20:02:30 +0000 (21:02 +0100)] 
gh-81925: Implement native thread ids for kFreeBSD (#111761)

---------

Co-authored-by: Antoine Pitrou <antoine@python.org>
23 months agoImprove error message for "float modulo by zero" (#111685)
Pavel Ovchinnikov [Thu, 9 Nov 2023 19:43:58 +0000 (22:43 +0300)] 
Improve error message for "float modulo by zero" (#111685)

23 months agogh-110875: Handle '.' properties in logging formatter configuration c… (GH-110943)
Vinay Sajip [Thu, 9 Nov 2023 18:55:22 +0000 (18:55 +0000)] 
gh-110875: Handle '.' properties in logging formatter configuration c… (GH-110943)

23 months agogh-111895: Convert definition list to bullet list for readability on mobile (#111898)
Hugo van Kemenade [Thu, 9 Nov 2023 18:50:27 +0000 (20:50 +0200)] 
gh-111895: Convert definition list to bullet list for readability on mobile (#111898)

Convert definition list to bullet list for readability on mobile

23 months agogh-111786: Optimize for space for _PyEval_EvalFrameDefault on MSVC for PGO (#111794)
Michael Droettboom [Thu, 9 Nov 2023 18:41:40 +0000 (13:41 -0500)] 
gh-111786: Optimize for space for _PyEval_EvalFrameDefault on MSVC for PGO (#111794)

In PGO mode, this function caused a compiler error in MSVC.
It turns out that optimizing for space only save the day, and is even faster.
However, without PGO, this is neither necessary nor slower.

2 years agogh-111881: Import doctest lazily in libregrtest (#111884)
Victor Stinner [Thu, 9 Nov 2023 15:00:10 +0000 (16:00 +0100)] 
gh-111881: Import doctest lazily in libregrtest (#111884)

In most cases, doctest is not needed. So don't always import it at
startup. The change reduces the number of modules already
imported when a test is run.

2 years agoAdd detail to comment on range of random.random() (gh-111868)
zipperer [Thu, 9 Nov 2023 14:58:04 +0000 (08:58 -0600)] 
Add detail to comment on range of random.random() (gh-111868)

---------

Co-authored-by: Raymond Hettinger <rhettinger@users.noreply.github.com>
2 years agogh-108303: Move more files to `Lib/test/test_module` (#111880)
Nikita Sobolev [Thu, 9 Nov 2023 14:42:34 +0000 (17:42 +0300)] 
gh-108303: Move more files to `Lib/test/test_module` (#111880)

2 years agogh-111881: Use lazy import in test.support (#111885)
Victor Stinner [Thu, 9 Nov 2023 14:38:13 +0000 (15:38 +0100)] 
gh-111881: Use lazy import in test.support (#111885)

* Import lazily getpass in test.support
* Only import ctypes on Windows in test.support.os_helper.

2 years agogh-108303: Move config parser data to `Lib/test/configparserdata/` (gh-111879)
Nikita Sobolev [Thu, 9 Nov 2023 13:52:32 +0000 (16:52 +0300)] 
gh-108303: Move config parser data to `Lib/test/configparserdata/` (gh-111879)

2 years agoGH-111843: Tier 2 exponential backoff (GH-111850)
Mark Shannon [Thu, 9 Nov 2023 13:49:51 +0000 (13:49 +0000)] 
GH-111843: Tier 2 exponential backoff (GH-111850)

2 years agoGH-109369: Exit tier 2 if executor is invalid (GH-111657)
Mark Shannon [Thu, 9 Nov 2023 11:19:51 +0000 (11:19 +0000)] 
GH-109369: Exit tier 2 if executor is invalid (GH-111657)

2 years agogh-111835: Add seekable method to mmap.mmap (gh-111852)
Donghee Na [Thu, 9 Nov 2023 11:13:35 +0000 (11:13 +0000)] 
gh-111835: Add seekable method to mmap.mmap (gh-111852)

2 years agogh-111354: remove comparisons with enum values, variable reuse, unused imports in...
Irit Katriel [Thu, 9 Nov 2023 10:27:20 +0000 (10:27 +0000)] 
gh-111354: remove comparisons with enum values, variable reuse, unused imports in genobject.c (#111708)

2 years agoGH-111804: Drop posix.fallocate() under WASI (GH-111869)
Brett Cannon [Thu, 9 Nov 2023 01:20:35 +0000 (17:20 -0800)] 
GH-111804: Drop posix.fallocate() under WASI (GH-111869)

Drop posix.fallocate() under WASI.

The underlying POSIX function, posix_fallocate(), was found to vary too
much between implementations to remain in WASI. As such, while it was
available in WASI preview1, it's been dropped in preview2.

2 years agogh-111569: Implement Python critical section API (gh-111571)
Sam Gross [Wed, 8 Nov 2023 22:39:29 +0000 (17:39 -0500)] 
gh-111569: Implement Python critical section API (gh-111571)

Critical sections are helpers to replace the global interpreter lock
with finer grained locking.  They provide similar guarantees to the GIL
and avoid the deadlock risk that plain locking involves.  Critical
sections are implicitly ended whenever the GIL would be released.  They
are resumed when the GIL would be acquired.  Nested critical sections
behave as if the sections were interleaved.

2 years agogh-110543: Fix CodeType.replace in presence of comprehensions (#110586)
Jelle Zijlstra [Wed, 8 Nov 2023 20:11:59 +0000 (12:11 -0800)] 
gh-110543: Fix CodeType.replace in presence of comprehensions (#110586)

2 years agoRemove redundant check in dbm.open() (GH-111844)
Serhiy Storchaka [Wed, 8 Nov 2023 17:42:41 +0000 (19:42 +0200)] 
Remove redundant check in dbm.open() (GH-111844)

PyUnicode_FSConverter() already checks for embedded null characters.

2 years agogh-111495: Add tests for PyList C API (#111562)
Kalyan [Wed, 8 Nov 2023 17:10:53 +0000 (22:40 +0530)] 
gh-111495: Add tests for PyList C API (#111562)

Signed-off-by: kalyanr <kalyan.ben10@live.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2 years agogh-68166: Tkinter: Add tests and examples for element_create() (GH-111453)
Serhiy Storchaka [Wed, 8 Nov 2023 16:25:58 +0000 (18:25 +0200)] 
gh-68166: Tkinter: Add tests and examples for element_create() (GH-111453)

* Remove mention of "vsapi" element type from the documentation.
* Add tests for element_create() and other ttk.Style methods.
* Add examples for element_create() in the documentation.

2 years agogh-111246: Remove listening Unix socket on close (#111483)
Pierre Ossman (ThinLinc team) [Wed, 8 Nov 2023 16:10:10 +0000 (17:10 +0100)] 
gh-111246: Remove listening Unix socket on close (#111483)

Try to clean up the socket file we create so we don't add unused noise to the file system.