If the error handler is used, a new bytes object is created to set as
the object attribute of UnicodeDecodeError, and that bytes object then
replaces the original data. A pointer to the decoded data will became invalid
after destroying that temporary bytes object. So we need other way to return
the first invalid escape from _PyUnicode_DecodeUnicodeEscapeInternal().
_PyBytes_DecodeEscape() does not have such issue, because it does not
use the error handlers registry, but it should be changed for compatibility
with _PyUnicode_DecodeUnicodeEscapeInternal().
(cherry picked from commit 9f69a58623)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* Ensure that created files and dirs are always removed after test.
Now addCleanup() does not conflict with tearDown().
* Use os_helper.unlink() and os_helper.rmdir().
* Import TESTFN from os_helper.
(cherry picked from commit e29171bf8a)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
gh-133940: test_strftime incorrectly calculates expected week (GH-134281)
Let the system determine the correct tm_wday and tm_isdst.
(cherry picked from commit e3dda8f818)
Co-authored-by: Gustaf <79180496+GGyll@users.noreply.github.com>
In 3.13.3 we accidentally broke the interface for custom task factory. Factory authors added workarounds.
This PR (for 3.13.4) unbreaks task factories that haven't made a workaround yet while also supporting those that have.
NOTE: The custom task factory API will change to what we accidentally released in 3.13.3.
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>
This fixes a crash in `_PyObject_TryGetInstanceAttribute` due to the use
of `_PyDictKeys_StringLookup` on an unlocked dictionary that may be
concurrently modified.
The underlying bug was already fixed in 3.14 and the main branch.
(partially cherry picked from commit 1b15c89a17)
gh-133744: Fix multiprocessing interrupt test: add an event (#133746)
Add an event to synchronize the parent process with the child
process: wait until the child process starts sleeping.
(cherry picked from commit c2989b7070)
When calling .close() the HTMLParser should flush all remaining content,
even when that content is in an unclosed script or style tag.
(cherry picked from commit 53383e90e4)
Co-authored-by: Waylan Limberg <waylan.limberg@icloud.com>
gh-132642: document how to render human-readable `timedelta` objects (GH-133825)
(cherry picked from commit efcc42ba70)
Co-authored-by: Kentaro Jay Takahashi <64148935+KentaroJay@users.noreply.github.com>
gh-133519: Add console to resources in libregrtest (GH-133520)
Add console to resources in libregrtest
(cherry picked from commit 4274b47156)
Co-authored-by: AN Long <aisk@users.noreply.github.com>
According to the HTML5 spec, named character references in attribute values
should only be processed if they are not followed by an ASCII alphanumeric,
or an equals sign.
(cherry picked from commit 77b14a6d58)
https: //html.spec.whatwg.org/multipage/parsing.html#named-character-reference-state
Co-authored-by: Sascha Ißbrücker <sascha.issbruecker@googlemail.com>
The function `dict_set_fromkeys()` adds elements of a set to an existing
dictionary. The size of the expanded dictionary was estimated with
`PySet_GET_SIZE(iterable)`, which did not take into account the size of the
existing dictionary.
(cherry picked from commit 421ba589d0)
Co-authored-by: Angela Liss <59097311+angela-tarantula@users.noreply.github.com>
(cherry picked from commit 0c5151bc81)
Co-authored-by: Sergey Miryanov <sergey.miryanov@gmail.com>
Co-authored-by: Tomas R. <tomas.roun8@gmail.com>
Co-authored-by: Chris Eibl <138194463+chris-eibl@users.noreply.github.com>
(cherry picked from commit 07f416a3f0)
Co-authored-by: Chris Eibl <138194463+chris-eibl@users.noreply.github.com>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
To support virtual terminal mode in Windows PYREPL, we need a scanner
to read over the supported escaped VT sequences.
Windows REPL input was using virtual key mode, which does not support
terminal escape sequences. This patch calls `SetConsoleMode` properly
when initializing and send sequences to enable bracketed-paste modes
to support verbatim copy-and-paste.
(cherry picked from commit a65366ed87)
Co-authored-by: Y5 <124019959+y5c4l3@users.noreply.github.com>
Signed-off-by: y5c4l3 <y5c4l3@proton.me>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
Co-authored-by: Dustin L. Howett <dustin@howett.net>
Co-authored-by: wheeheee <104880306+wheeheee@users.noreply.github.com>
[tests] test_subprocess maybe avoid a timeout race condition? (GH-133420)
The few buildbot failures on https://github.com/python/cpython/pull/133103
are possibly just due to racing a child process launch and exit?
(cherry picked from commit b64aa302d7)
Co-authored-by: Gregory P. Smith <greg@krypto.org>
gh-133089: Use original timeout value for `TimeoutExpired` when the func `subprocess.run` is called with a timeout (GH-133103)
(cherry picked from commit 2bbcaedb75)
Signed-off-by: Manjusaka <me@manjusaka.me>
Co-authored-by: Nadeshiko Manju <me@manjusaka.me>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
* Ensure that destructors are called in the test that created interpreters, not after finishing it.
* Try to create/run interpreters in threads simultaneously.
* Mark tests that requires over 6GB of memory with bigmemtest.
(cherry picked from commit 61b50a98b4)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
In the C implementation, remove __reduce__ and __reduce_ex__ methods
that always raise TypeError and restore __getstate__ methods that always
raise TypeErrori.
This restores fine details of the pre-3.12 behavior and unifies
both implementations.
(cherry picked from commit e9253ebf74)
The X/Open curses specification[0] and ncurses documentation[1]
both state that subwindows must be deleted before the main window.
Deleting the windows in the wrong order causes a double-free with
NetBSD's curses implementation.
To fix this, keep track of the original window object in the subwindow
object, and keep a reference to the original for the lifetime of
the subwindow.
[0] https://pubs.opengroup.org/onlinepubs/7908799/xcurses/delwin.html
[1] https://invisible-island.net/ncurses/man/curs_window.3x.html
(cherry picked from commit 0af61fe2f4)
Co-authored-by: Michael Forney <mforney@mforney.org>
gh-114713: Revert gh-114731 (GH-133330)
Revert "gh-114713: Handle case of an empty string passed to `zoneinfo.ZoneInfo` (GH-114731)"
This reverts commit 884df116d7.
(cherry picked from commit fe44fc4f43)
Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>