gh-120380: fix Python implementation of `pickle.Pickler` for `bytes` and `bytearray` objects in protocol version 5. (GH-120422)
(cherry picked from commit 7595e6743a)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
gh-120661: improve example for basic type hints (GH-120934)
(cherry picked from commit bb057ea107)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
gh-120671: Fix PY_CHECK_CC_WARNING() in configure.ac (GH-120822)
Add missing space in AS_VAR_APPEND() on CFLAGS.
(cherry picked from commit 2106c9bef0)
Co-authored-by: Michael Allwright <allsey87@gmail.com>
PyDict_Next no longer locks the dictionary in the free-threaded build. Locking
around individual PyDict_Next calls is not sufficient because the function
returns borrowed references and because it allows concurrent modifications
during the iteraiton loop.
The internal locking also interferes with correct external synchronization
because it may suspend outer critical sections created by the caller.
(cherry picked from commit 375b723d58)
Co-authored-by: Sam Gross <colesbury@gmail.com>
Moves the logic to update the type's dictionary to its own function in order
to make the lock scoping more clear.
Also, ensure that `name` is decref'd on the error path.
(cherry picked from commit dee63cb359)
Co-authored-by: Sam Gross <colesbury@gmail.com>
* Add an InternalDocs file describing how interning should work and how to use it.
* Add internal functions to *explicitly* request what kind of interning is done:
- `_PyUnicode_InternMortal`
- `_PyUnicode_InternImmortal`
- `_PyUnicode_InternStatic`
* Switch uses of `PyUnicode_InternInPlace` to those.
* Disallow using `_Py_SetImmortal` on strings directly.
You should use `_PyUnicode_InternImmortal` instead:
- Strings should be interned before immortalization, otherwise you're possibly
interning a immortalizing copy.
- `_Py_SetImmortal` doesn't handle the `SSTATE_INTERNED_MORTAL` to
`SSTATE_INTERNED_IMMORTAL` update, and those flags can't be changed in
backports, as they are now part of public API and version-specific ABI.
* Add private `_only_immortal` argument for `sys.getunicodeinternedsize`, used in refleak test machinery.
* Make sure the statically allocated string singletons are unique. This means these sets are now disjoint:
- `_Py_ID`
- `_Py_STR` (including the empty string)
- one-character latin-1 singletons
Now, when you intern a singleton, that exact singleton will be interned.
* Add a `_Py_LATIN1_CHR` macro, use it instead of `_Py_ID`/`_Py_STR` for one-character latin-1 singletons everywhere (including Clinic).
* Intern `_Py_STR` singletons at startup.
* For free-threaded builds, intern `_Py_LATIN1_CHR` singletons at startup.
* Beef up the tests. Cover internal details (marked with `@cpython_only`).
* Add lots of assertions
Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
- gh-119521: Rename IncompleteInputError to _IncompleteInputError and remove from public API/ABI (GH-119680)
(cherry picked from commit ce1064e4c9)
- gh-119521: Use `PyAPI_DATA`, not `extern`, for `_PyExc_IncompleteInputError` (GH-120955)
(cherry picked from commit ac61d58db0)
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
docs: puremagic.what() as replacement for imghdr.what() (GH-120871)
(cherry picked from commit 22b8a35d6e)
Co-authored-by: Christian Clauss <cclauss@me.com>
gh-120373: Mark test_audit.test_http as requiring the network resource (GH-120374)
(cherry picked from commit b0e1c51882)
Co-authored-by: Itamar Oren <itamarost@gmail.com>
Now the null character is always represented as \xc0\x80 for
Tcl_NewStringObj().
(cherry picked from commit c38e2f64d0)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
The integer part of the timestamp can be rounded up, while the millisecond
calculation truncates, causing the log timestamp to be wrong by up to 999 ms
(affected roughly 1 in 8 million timestamps).
(cherry picked from commit 1500a23f33)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Accessing the Tkinter object's string representation no longer converts
the underlying Tcl object to a string on Windows.
(cherry picked from commit f4ddaa3967)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
gh-120896: Fix typo in version changed note of `urllib.parse.urlparse()` (GH-120898)
(cherry picked from commit b6fa8fe86a)
Co-authored-by: Nice Zombies <nineteendo19d0@gmail.com>
Also refactor the "state" option tests for other ttk widgets.
(cherry picked from commit 974a978631)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
The tests are now passed with the current version of Tcl/Tk under
development (8.7b1+ and 9.0b3+).
The following changes were also made to make the tests more flexible:
* Helper methods like checkParam() now interpret the expected error message
as a regular expression instead of a literal.
* Add support of new arguments in checkEnumParam():
- allow_empty=True skips testing with empty string;
- fullname= specifies the name for error message if it differs from the
option name;
- sort=True sorts values for error message.
* Add support of the allow_empty argument in checkReliefParam():
allow_empty=True adds an empty string to the list of accepted values.
* Attributes _clip_highlightthickness, _clip_pad and _clip_borderwidth
specify how negative values of options -highlightthickness, -padx, -pady
and -borderwidth are handled.
* Use global variables for some common error messages.
(cherry picked from commit 6ad26de6e8)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
This makes the following macros public as part of the non-limited C-API for
locking a single object or two objects at once.
* `Py_BEGIN_CRITICAL_SECTION(op)` / `Py_END_CRITICAL_SECTION()`
* `Py_BEGIN_CRITICAL_SECTION2(a, b)` / `Py_END_CRITICAL_SECTION2()`
The supporting functions and structs used by the macros are also exposed for
cases where C macros are not available.
(cherry picked from commit 8f17d69b7b)
gh-120773: document introspective attributes of an async generator object in the inspect module (GH-120778)
(cherry picked from commit 83d3d7aace)
Co-authored-by: blhsing <blhsing@gmail.com>
Update the documentation howto index page and group docs into 3 logical sections (GH-119366)
(cherry picked from commit a26d27e7ee)
Includes a follow-up fix to properly merge GH-119877:
* Add a link to free-threading HOWTO to the index (GH-120703)
(cherry picked from commit 45d5cab533)
Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
Co-authored-by: Ned Batchelder <ned@nedbatchelder.com>
gh-118820: Zero-valued flag enum has no name (GH-118848)
(cherry picked from commit ed5ae6c4d7)
Co-authored-by: Nice Zombies <nineteendo19d0@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
gh-120732: Fix `name` passing to `Mock`, when using kwargs to `create_autospec` (GH-120737)
(cherry picked from commit 1e4815692f)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
gh-120635: Avoid leaking processes in test_pyrepl (GH-120676)
If the child process takes longer than SHORT_TIMEOUT seconds to
complete, kill the process but then wait until it completes with no
timeout to not leak child processes.
(cherry picked from commit 0f3e36454d)
Co-authored-by: Victor Stinner <vstinner@python.org>