Commit graph

28466 commits

Author SHA1 Message Date
Gregory P. Smith 10e9bb13b8
gh-112334: Regression test that vfork is used when expected. (#112734)
Regression test that vfork is used when expected by subprocess.

This is written integration test style, it uses strace if it is present and appears to work to find out what system call actually gets used in different scenarios.

Test coverage is added for the default behavior and that of each of the specific arguments that must disable the use of vfork.  obviously not an entire test matrix, but it covers the most important aspects.

If there are ever issues with this test being flaky or failing on new platforms, rather than try and adapt it for all possible platforms, feel free to narrow the range it gets tested on when appropriate. That is not likely to reduce coverage.
2023-12-09 00:18:35 +00:00
Raymond Hettinger f3bff4ee9d
gh-112540: Support zero inputs in geometric_mean() (gh-112880) 2023-12-08 12:05:56 -06:00
Barney Gale 76929fdeeb
GH-110109: Add pathlib._PurePathBase (#110670)
Add private `pathlib._PurePathBase` class: a private superclass of both `PurePath` and `_PathBase`. Unlike `PurePath`, it does not define any of these special methods: `__fspath__`, `__bytes__`, `__reduce__`, `__hash__`, `__eq__`, `__lt__`, `__le__`, `__gt__`, `__ge__`. Its initializer and path joining methods accept only strings, not os.PathLike objects more broadly.

This is important for supporting *virtual paths*: user subclasses of `_PathBase` that provide access to archive files, FTP servers, etc. In these classes, the above methods should be implemented by users only as appropriate, with due consideration for the hash/equality of any backing objects, such as file objects or sockets.
2023-12-08 17:39:04 +00:00
Ronald Oussoren 15a80b15af
gh-110820: Make sure processor specific defines are correct for Universal 2 build on macOS (#112828)
* gh-110820: Make sure processor specific defines are correct for Universal 2 build on macOS

A number of processor specific defines are different for x86-64 and
arm64, and need to be adjusted in pymacconfig.h.

* remove debug stuf
2023-12-08 10:09:34 +01:00
Ronald Oussoren bf0beae6a0
gh-110017: Disable test_signal.test_stress_modifying_handlers on macOS (#112834)
Test test_stress_modifying_handlers in test_signal can crash
the interpreter due to a bug in macOS. Filed as FB13453490
with Apple.
2023-12-07 19:41:27 +01:00
AN Long a955fd68d6
gh-112278: Disable WMI queries on Windows after they time out (GH-112658) 2023-12-07 17:26:29 +00:00
Serhiy Storchaka b2923a61a1
gh-79325: Fix recursion error in TemporaryDirectory cleanup on Windows (GH-112762) 2023-12-07 17:21:36 +00:00
Søren Løvborg 81c16cd94e
gh-91133: tempfile.TemporaryDirectory: fix symlink bug in cleanup (GH-99930)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-12-07 18:04:06 +02:00
Seth Michael Larson 21221c398f
gh-112302: Add Software Bill-of-Materials (SBOM) tracking for dependencies (#112303) 2023-12-07 18:01:58 +02:00
andrewluotechnologies 9c3458e058
gh-112125: Fix None.__ne__(None) returning NotImplemented instead of False (#112504) 2023-12-07 13:56:01 +01:00
Tian Gao 3d712a9f4c
gh-102980: Redirect output of pdb's interact command, add tests and improve docs (#111194) 2023-12-07 11:19:33 +00:00
Ronald Oussoren 4b125dd31a
gh-51944: Add missing macOS constants to termios (#112823)
* gh-51944: Add some macOS constants to termios

This changeset adds all public constants in <termio.h>
and <sys/termios.h> on macOS that weren't present
already.

Based on the macOS 14.2 SDK

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-12-07 11:27:30 +01:00
Kushal Das 4ba15de191
gh-74616: Raise ValueError in case of null character in input prompt (GH-1738)
If the input prompt to the builtin input function on terminal has any null
character, then raise ValueError instead of silently truncating it.

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-12-07 10:22:52 +00:00
Serhiy Storchaka 8660fb7fd7
gh-112660: Do not clear arbitrary errors on import (GH-112661)
Previously arbitrary errors could be cleared during formatting error
messages for ImportError or AttributeError for modules. Now all
unexpected errors are reported.
2023-12-07 12:19:43 +02:00
Ronald Oussoren 953ee622b3
gh-109981: Fix support.fd_count() on macOS 14 (#112797)
Use scanning "/dev/fd/" on macOS in support.fd_count(). That's both more efficient than scanning all possible file descriptors, and avoids crashing the interpreter when there are open "guarded" file descriptors.

"Guarded" file descriptors are a macOS feature where file descriptors used by system libraries are marked and cause hard crashes when used by "user" code.

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-12-07 10:30:15 +01:00
Pablo Galindo Salgado 16448cab44
gh-112730: Use color to highlight error locations (gh-112732)
Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2023-12-06 23:29:54 +01:00
Serhiy Storchaka cc7e45cc57
gh-75666: Tkinter: "unbind(sequence, funcid)" now only unbinds "funcid" (GH-111322)
Previously, "widget.unbind(sequence, funcid)" destroyed the current binding
for "sequence", leaving "sequence" unbound, and deleted the "funcid"
command.

Now it removes only "funcid" from the binding for "sequence", keeping
other commands, and deletes the "funcid" command.
It leaves "sequence" unbound only if "funcid" was the last bound command.

Co-authored-by: GiovanniL <13402461+GiovaLomba@users.noreply.github.com>
2023-12-06 16:42:15 +02:00
Victor Stinner 828451dfde
gh-111545: Add Py_HashPointer() function (#112096)
* Implement _Py_HashPointerRaw() as a static inline function.
* Add Py_HashPointer() tests to test_capi.test_hash.
* Keep _Py_HashPointer() function as an alias to Py_HashPointer().
2023-12-06 15:09:22 +01:00
Miro Hrončok d384813ff1
gh-112769: test_zlib: Fix comparison of ZLIB_RUNTIME_VERSION with non-int suffix (GH-112771)
zlib-ng defines the version as "1.3.0.zlib-ng".
2023-12-05 21:39:28 +02:00
Zackery Spytz 11d88a178b
bpo-35332: Handle os.close() errors in shutil.rmtree() (GH-23766)
* Ignore os.close() errors when ignore_errors is True.
* Pass os.close() errors to the error handler if specified.
* os.close no longer retried after error.

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-12-05 19:09:39 +02:00
Ethan Furman de6bca9564
gh-112328: [Enum] Make some private attributes public. (GH-112514)
* [Enum] Make some private attributes public.

- ``_EnumDict`` --> ``EnumDict``
- ``EnumDict._member_names`` --> ``EnumDict.member_names``
- ``Enum._add_alias_``
- ``Enum._add_value_alias_``

---------

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2023-12-05 08:27:36 -08:00
Serhiy Storchaka 563ccded6e
gh-94692: Only catch OSError in shutil.rmtree() (#112756)
Previously a symlink attack resistant version of shutil.rmtree() could ignore
or pass to the error handler arbitrary exception when invalid arguments
were provided.
2023-12-05 16:40:49 +01:00
Diego Russo bc68f4a4ab
gh-110190: Fix ctypes structs with array on Arm (#112604)
Set MAX_STRUCT_SIZE to 32 in stgdict.c when on Arm platforms.
This because on Arm platforms structs with at most 4 elements of any
floating point type values can be passed through registers. If the type
is double the maximum size of the struct is 32 bytes.
On x86-64 Linux, it's maximum 16 bytes hence we need to differentiate.
2023-12-05 16:07:50 +01:00
Ken Jin 8cdfee1bb9
bpo-43153: Don't mask PermissionError with NotADirectoryError during tempdirectory cleanup (GH-29940)
Co-authored-by: andrei kulakov <andrei.avk@gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-12-05 15:30:59 +02:00
Jeffrey Kintscher 268415bbb3
gh-81441: shutil.rmtree() FileNotFoundError race condition (GH-14064)
Ignore missing files and directories while enumerating
directory entries in shutil.rmtree().

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-12-05 09:33:51 +00:00
pan324 81ee026091
gh-82300: Add track parameter to multiprocessing.shared_memory (#110778)
Add a track parameter to shared memory to allow resource tracking via the side-launched resource tracker process to be disabled on platforms that use it (POSIX).

This allows people who do not want automated cleanup at process exit because they are using the shared memory with processes not participating in Python's resource tracking to use the shared_memory API.

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>
Co-authored-by: Antoine Pitrou <pitrou@free.fr>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-12-05 00:11:44 -08:00
Constantin Hong aa5bee30ab
gh-102130: Support tab completion in cmd for Libedit. (GH-107748)
---

Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
2023-12-05 08:24:56 +01:00
Russell Keith-Magee dc824c5dc1
gh-112736: Refactor del-safe symbol handling in subprocess (#112738)
Refactor delete-safe symbol handling in subprocess.

Only module globals are force-cleared during interpreter finalization, using a class reference instead of individually listing the constants everywhere is simpler.
2023-12-04 20:23:17 -08:00
Barney Gale 304a1b3f3a
GH-112727: Speed up pathlib.Path.absolute() (#112728)
Use `_from_parsed_parts()` to create a pre-joined/pre-parsed path, rather
than passing multiple arguments to `with_segments()`

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-12-04 23:21:39 +00:00
Gregory P. Smith 9fe7655c6c
gh-112334: Restore subprocess's use of vfork() & fix extra_groups=[] behavior (#112617)
Restore `subprocess`'s intended use of `vfork()` by default for performance on Linux;
also fixes the behavior of `extra_groups=[]` which was unintentionally broken in 3.12.0:

Fixed a performance regression in 3.12's :mod:`subprocess` on Linux where it
would no longer use the fast-path ``vfork()`` system call when it could have
due to a logic bug, instead falling back to the safe but slower ``fork()``.

Also fixed a security bug introduced in 3.12.0.  If a value of ``extra_groups=[]``
was passed to :mod:`subprocess.Popen` or related APIs, the underlying
``setgroups(0, NULL)`` system call to clear the groups list would not be made
in the child process prior to ``exec()``.

The security issue was identified via code inspection in the process of
fixing the first bug.  Thanks to @vain for the detailed report and
analysis in the initial bug on Github.

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-12-04 15:08:19 -08:00
Gregory P. Smith 4eddb4c9d9
gh-105967: Work around a macOS bug, limit zlib C library crc32 API calls to 1gig (#112615)
Work around a macOS bug, limit zlib crc32 calls to 1GiB.

Without this, `zlib.crc32` and `binascii.crc32` could produce incorrect
results on multi-gigabyte inputs depending on the macOS version's Apple
supplied zlib implementation.
2023-12-04 12:04:05 -08:00
Kamil Turek a1551b48ee
gh-103363: Add follow_symlinks argument to pathlib.Path.owner() and group() (#107962) 2023-12-04 19:42:01 +00:00
Alex Waygood 2ed20d3bd8
gh-74690: Avoid a costly type check where possible in _ProtocolMeta.__subclasscheck__ (#112717) 2023-12-04 19:35:46 +00:00
Thomas Bininda 1e4680ce52
gh-112516: Update bundled pip version to 23.3.1 (gh-112517) 2023-12-04 18:27:57 +01:00
Serhiy Storchaka e08b70fab1
gh-108927: Fix removing testing modules from sys.modules (GH-108952)
It breaks import machinery if the test module has submodules used in
other tests.
2023-12-04 15:43:27 +00:00
Alex Waygood c718ab92a5
gh-74690: Optimise isinstance() and issubclass() calls against runtime-checkable protocols by avoiding costly super() calls (#112708) 2023-12-04 15:41:41 +00:00
Serhiy Storchaka 6ca9d3e017
gh-109786: Fix leaks and crash when re-enter itertools.pairwise.__next__() (GH-109788) 2023-12-04 11:47:55 +00:00
Serhiy Storchaka c74e9fb189
gh-110275: Named tuple's __replace__() now raises TypeError for invalid arguments (GH-110299) 2023-12-04 13:30:32 +02:00
Serhiy Storchaka da6760bdf5
gh-65210: Add const qualifiers in PyArg_VaParseTupleAndKeywords() (GH-105958)
Change the declaration of the keywords parameter in functions
PyArg_ParseTupleAndKeywords() and PyArg_VaParseTupleAndKeywords() from `char **`
to `char * const *` in C and `const char * const *` in C++.

It makes these functions compatible with argument of type `const char * const *`,
`const char **` or `char * const *` in C++ and `char * const *` in C
without explicit type cast.

Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
2023-12-04 13:14:56 +02:00
Serhiy Storchaka dee7beeb4f
bpo-34392: Add sys. _is_interned() (GH-8755) 2023-12-04 11:09:06 +02:00
chilaxan 0e732d0997
gh-112625: Protect bytearray from being freed by misbehaving iterator inside bytearray.join (GH-112626) 2023-12-04 08:15:43 +00:00
Irit Katriel 97857ac058
gh-112645: remove deprecation warning for use of onerror in shutil.rmtree (#112659) 2023-12-03 14:02:37 +00:00
Victor Stinner 1f2a676785
gh-106560: Fix redundant declarations in Include/ (#112611)
Don't declare PyBool_Type, PyLong_Type and PySys_Audit() twice, but
only once.

Compiler warnings seen by building Python with gcc -Wredundant-decls.
2023-12-03 12:16:31 +01:00
Shantanu 29e6c7b68a
gh-112578: Fix RuntimeWarning when running zipfile (GH-112579) 2023-12-03 13:09:29 +02:00
Nikita Sobolev a9574c68f0
gh-112139: Add inspect.Signature.format and use it in pydoc (#112143)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-12-02 15:39:43 -08:00
Nikita Sobolev a35a305098
gh-112618: Make Annotated cache typed (#112619)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-12-02 16:10:19 +00:00
William Wen 939fc6d6ea
gh-106922: Support multi-line error locations in traceback (attempt 2) (#112097) 2023-12-01 22:18:16 +00:00
Zackery Spytz 0daf555c6f
bpo-37013: Fix the error handling in socket.if_indextoname() (GH-13503)
* Fix a crash when pass UINT_MAX.
* Fix an integer overflow on 64-bit non-Windows platforms.
2023-12-01 15:16:49 +00:00
Tian Gao c2982380f8
gh-112510: Add readline.backend for the backend readline uses (GH-112511)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Donghee Na <donghee.na92@gmail.com>
2023-12-01 14:05:55 +00:00
Pablo Galindo Salgado a73aa48e6b
gh-112367: Only free perf trampoline arenas at shutdown (#112368)
Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
2023-12-01 13:20:51 +00:00