If `Py_IsFinalizing()` is true, non-daemon threads (other than the current one)
are done, and daemon threads are prevented from running, so they
cannot finalize themselves and become done. Joining them (without timeout)
would block forever.
Raise PythonFinalizationError instead of hanging.
Raise even when a timeout is given, for consistency with trying to join your own thread.
See gh-123940 for a use case: calling `join()` from `__del__`. This is
ill-advised, but an exception should at least make it easier to diagnose.
This was in C version from beginning, but available only
on conditional compilation (EXTRA_FUNCTIONALITY). Current
patch adds function to create IEEE contexts to the
pure-python module as well.
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
* gh-133005: Support `tarfile.open(mode="w|xz", preset=...)`
Support passing the `preset` option to `tarfile.open` when the file
is open with `mode="w|xz"`. This aligns the behavior with `"w:xz"`
mode.
* Also raise an error for `compresslevel` or `preset` with wrong mode
Raise an error if `compresslevel` or `preset` argument is specified
for stream mode with incorrect compression. This should reduce the risk
of mistakes and align the stream modes with regular modes, that raise
an implicit TypeError on unsupported arguments.
* Apply suggestions from code review
Co-authored-by: Brian Schubert <brianm.schubert@gmail.com>
Clearly note that this is primarily intended for users for who zlib/gzip is a bottleneck.
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
* Support arbitrary bytes-like objects, not only bytes, in fcntl().
* The fcntl() buffer argument is now null-terminated.
* Automatically retry an ioctl() system calls failing with EINTR.
* Release the GIL for an ioctl() system call even for large bytes-like object.
* Do not silence arbitrary errors whet try to get a buffer.
* Optimize argument parsing, check the argument type before trying to get
a buffer or convert it to integer.
* Fix some error messages.
* gh-129327: revise hashlib documentation to account for FIPS removing sha1
More generally, the current documentation is a bit scattered, talking
about what terms are "equal" despite those terms not being very
interesting and given the term "secure hash", probably wrong (because
md5 and sha1 are not secure anymore).
Let's talk about cryptographically secure instead, and note that two of
them aren't. And then we can also link to the source for NIST going
through the removal process for SHA1.
* Add Gregors Suggestion
* Clean up
---------
Co-authored-by: Eli Schwartz <eschwartz@gentoo.org>
- Explicitly say that isinstance/issubclass do not work on non-runtime checkable
protocols.
- Move the sentence "This raises TypeError when applied to a non-protocol class". It
took me quite some time to decide what "this" was here: it refers to applying the
decorator, not to an isinstance() call.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Previously only an integer packed in a tuple was accepted, while
getsockname() could return a raw integer.
Now the result of getsockname() is always acceptable as an address.
In `_is_local_authority()`, return early if the authority matches the
machine hostname from `socket.gethostname()`, rather than resolving the
names and matching IP addresses.
Now all protocols always accept the Bluetooth address as string and
getsockname() always returns the Bluetooth address as string.
* BTPROTO_SCO now accepts not only bytes, but str.
* BTPROTO_SCO now checks address for embedded null.
* On *BSD, BTPROTO_HCI now accepts str instead of bytes.
* On FreeBSD, getsockname() for BTPROTO_HCI now returns str instead of bytes.
* On NetBSD and DragonFly BDS, BTPROTO_HCI now checks address for embedded null.
Add optional *add_scheme* argument to `urllib.request.pathname2url()`; when
set to true, a complete URL is returned. Likewise add optional
*require_scheme* argument to `url2pathname()`; when set to true, a complete
URL is accepted.
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Add extra audit hooks to catch C function calling from ctypes,
reading/writing files through readline and executing external
programs through _posixsubprocess.
* Make audit-tests for open pass when readline.append_history_file is unavailable
* Less direct testing of _posixsubprocess for audit hooks
* Also remove the audit hook from call_cdeclfunction now that _ctypes_callproc does it instead.
* reword the NEWS entry.
* mention readline in NEWS
* add versionchanged markers
* fix audit_events.rst versionadded
* doc lint
---------
Co-authored-by: Gregory P. Smith <greg@krypto.org>