Commit graph

13581 commits

Author SHA1 Message Date
Miss Islington (bot)
0403cb41bf
[3.12] gh-120289: Add external timer in traverse of _lsprof.Profiler (GH-121998) (#122001)
gh-120289: Add external timer in traverse of _lsprof.Profiler (GH-121998)
(cherry picked from commit eaf094c09b)

Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
2024-07-19 04:05:08 +00:00
Miss Islington (bot)
001584da03
[3.12] gh-120289: Disallow disable() and clear() in external timer to prevent use-after-free (GH-120297) (#121989)
gh-120289: Disallow disable() and clear() in external timer to prevent use-after-free (GH-120297)
(cherry picked from commit 1ab1778283)

Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
2024-07-18 16:37:49 -07:00
Miss Islington (bot)
106d6456ca
[3.12] gh-121791: Check for NULL in MethodDescriptor2_new in _testcapi (GH-121792) (#121840)
gh-121791: Check for `NULL` in `MethodDescriptor2_new` in `_testcapi` (GH-121792)
(cherry picked from commit 8b6d475581)

Co-authored-by: sobolevn <mail@sobolevn.me>
2024-07-16 08:51:50 +00:00
Serhiy Storchaka
027902b56f
[3.12] gh-120713: Normalize year with century for datetime.strftime (GH-120820) (GH-121145)
(cherry picked from commit 6d34938dc8)

Co-authored-by: blhsing <blhsing@gmail.com>
2024-06-29 06:54:27 +00:00
Miss Islington (bot)
5c06b34665
[3.12] gh-121137: Add missing Py_DECREF calls for ADDITEMS opcode of _pickle.c (GH-121136) (#121140)
gh-121137: Add missing Py_DECREF calls for ADDITEMS opcode of _pickle.c (GH-121136)

PyObject_GetAttr returns a new reference, but this reference is never decremented using Py_DECREF, so Py_DECREF calls to this referece are added
(cherry picked from commit 92893fd8dc)

Co-authored-by: Justin Applegate <70449145+Legoclones@users.noreply.github.com>
2024-06-28 16:17:51 -07:00
Miss Islington (bot)
d5a8d4b196
[3.12] gh-119614: Fix truncation of strings with embedded null characters in Tkinter (GH-120909) (GH-120939)
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>
2024-06-24 09:39:56 +00:00
Serhiy Storchaka
c525cb3a7b
[3.12] gh-101830: Fix Tcl_Obj to string conversion (GH-120884) (GH-120913)
Accessing the Tkinter object's string representation no longer converts
the underlying Tcl object to a string on Windows.
(cherry picked from commit f4ddaa3967)
2024-06-23 16:02:43 +00:00
Miss Islington (bot)
cde976d85c
[3.12] gh-119506: fix _io.TextIOWrapper.write() write during flush (GH-119507) (#119965)
gh-119506: fix `_io.TextIOWrapper.write()` write during flush (GH-119507)
(cherry picked from commit 52586f930f)

Co-authored-by: Radislav Chugunov <52372310+chgnrdv@users.noreply.github.com>
Co-authored-by: Inada Naoki <songofacandy@gmail.com>
2024-06-19 10:23:29 +00:00
Miss Islington (bot)
e004914045
[3.12] gh-120586: Fix several "unused function" warnings in posixmodule.c (GH-120588) (#120617)
gh-120586: Fix several "unused function" warnings in `posixmodule.c` (GH-120588)
(cherry picked from commit 3df2022931)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2024-06-17 07:01:15 +00:00
neonene
7719eefcce
[3.12] gh-71587: Drop local reference cache to _strptime module in _datetime (gh-120431)
The _strptime module object was cached in a static local variable (in the datetime.strptime() implementation).  That's a problem when it crosses isolation boundaries, such as reinitializing the runtme or between interpreters.  This change fixes the problem by dropping the static variable, instead always relying on the normal sys.modules cache (via PyImport_Import()).

(cherry picked from commit 127c1d2771, AKA gh-120224)
2024-06-13 12:47:46 -06:00
Miss Islington (bot)
ab30934365
[3.12] gh-120155: Add assertion to sre.c match_getindex() (GH-120402) (#120410)
gh-120155: Add assertion to sre.c match_getindex() (GH-120402)

Add an assertion to help static analyzers to detect that i*2 cannot
overflow.
(cherry picked from commit 42b25dd61f)

Co-authored-by: Victor Stinner <vstinner@python.org>
2024-06-12 13:57:45 +00:00
Miss Islington (bot)
ff980e3f7a
[3.12] gh-120155: Fix Coverity issue in zoneinfo load_data() (GH-120232) (#120311)
gh-120155: Fix Coverity issue in zoneinfo load_data() (GH-120232)

Declare the 'rv' varaible at the top of the load_data() function to
make sure that it's initialized before the first 'goto error' which
uses 'rv' (return rv).

Fix the Coverity issue:

Error: UNINIT (CWE-457):
Python-3.12.2/Modules/_zoneinfo.c:1233:5: skipped_decl: Jumping over declaration of ""rv"".
Python-3.12.2/Modules/_zoneinfo.c:1284:5: uninit_use: Using uninitialized value ""rv"".
  1282|       }
  1283|
  1284|->     return rv;
  1285|   }
  1286|
(cherry picked from commit b90bd3e5bb)

Co-authored-by: Victor Stinner <vstinner@python.org>
2024-06-10 10:12:25 +00:00
Miss Islington (bot)
46e69f8c25
[3.12] gh-120244: Fix re.sub() reference leak (GH-120245) (GH-120265)
(cherry picked from commit 38a25e9560)

Co-authored-by: neonene <53406459+neonene@users.noreply.github.com>
2024-06-08 14:10:44 +03:00
Miss Islington (bot)
ec139c8fae
[3.12] gh-112672: Fix builtin Tkinter with Tcl 9.0 (GH-112681) (GH-120209)
* Add declaration of Tcl_AppInit(), missing in Tcl 9.0.
* Use Tcl_Size instead of int where needed.

(cherry picked from commit e079935282)

Co-authored-by: Christopher Chavez <chrischavez@gmx.us>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-06-07 10:18:42 +00:00
Serhiy Storchaka
f98ec7574a
[3.12] gh-89928: Fix integer conversion of device numbers (GH-31794) (GH-120054)
Fix os.major(), os.minor() and os.makedev().
Support device numbers larger than 2**63-1.
Support non-existent device number (NODEV).
(cherry picked from commit 7111d9605f)
2024-06-04 17:12:13 +00:00
Victor Stinner
34a0e7a824
[3.12] Revert "[3.12] gh-69214: Fix fcntl.ioctl() request type (#119498) (#1… (#119905)
Revert "[3.12] gh-69214: Fix fcntl.ioctl() request type (#119498) (#119505)"

This reverts commit 078da88ad1.

The change modified how negative values, like termios.TIOCSWINSZ, was
treated and is actually backward incompatible.
2024-06-01 17:08:07 +02:00
Sam Gross
738cf21609
[3.12] gh-119585: Fix crash involving PyGILState_Release() and PyThreadState_Clear() (GH-119753) (#119861)
Make sure that `gilstate_counter` is not zero in when calling
`PyThreadState_Clear()`. A destructor called from `PyThreadState_Clear()` may
call back into `PyGILState_Ensure()` and `PyGILState_Release()`. If
`gilstate_counter` is zero, it will try to create a new thread state before
the current active thread state is destroyed, leading to an assertion failure
or crash.
(cherry picked from commit bcc1be39cb)
2024-05-31 15:42:09 +00:00
Serhiy Storchaka
d4680b9e17
[3.12] gh-103194: Fix Tkinter’s Tcl value type handling for Tcl 8.7/9.0 (GH-103846) (GH-119831)
Some of standard Tcl types were renamed, removed, or no longer
registered in Tcl 8.7/9.0. This change fixes automatic conversion of Tcl
values to Python values to avoid returning a Tcl_Obj where the primary
Python types (int, bool, str, bytes) were returned in older Tcl.
(cherry picked from commit 94e9585e99)

Co-authored-by: Christopher Chavez <chrischavez@gmx.us>
2024-05-31 09:15:53 +00:00
Steve Dower
e85e813bf1
gh-119690: Adds Unicode support for named pipes in _winapi (GH-119717)
Also backports a minor improvement to test_audit.
2024-05-30 15:40:23 +01:00
Nice Zombies
09a85eaa4c
gh-118263: Add additional arguments to path_t (Argument Clinic type) in posixmodule (GH-119608) 2024-05-28 11:13:01 +01:00
Victor Stinner
078da88ad1
[3.12] gh-69214: Fix fcntl.ioctl() request type (#119498) (#119505)
gh-69214: Fix fcntl.ioctl() request type (#119498)

Use an 'unsigned long' instead of an 'unsigned int' for the request
parameter of fcntl.ioctl() to support requests larger than UINT_MAX.

(cherry picked from commit 92fab3356f)
2024-05-24 12:53:41 +00:00
Eric Snow
0d5fe2c7b4
[3.12] gh-119213: Be More Careful About _PyArg_Parser.kwtuple Across Interpreters (gh-119331) (gh-119425)
_PyArg_Parser holds static global data generated for modules by Argument Clinic.  The _PyArg_Parser.kwtuple field is a tuple object, even though it's stored within a static global.  In some cases the tuple is statically allocated and thus it's okay that it gets shared by multiple interpreters.  However, in other cases the tuple is set lazily, allocated from the heap using the active interprepreter at the point the tuple is needed.

This is a problem once that interpreter is destroyed since _PyArg_Parser.kwtuple becomes at dangling pointer, leading to crashes.  It isn't a problem if the tuple is allocated under the main interpreter, since its lifetime is bound to the lifetime of the runtime.  The solution here is to temporarily switch to the main interpreter.  The alternative would be to always statically allocate the tuple.

This change also fixes a bug where only the most recent parser was added to the global linked list.

(cherry picked from commit 81865002ae)
2024-05-22 22:26:58 +00:00
Nice Zombies
874a4f7d08
gh-118507 : Refactor ntpath native functions (gh-119381)
This refactoring will make future backports easier without changing behaviours,
apart from correcting a bug when passing a pipe to `ntpath.isfile`.
2024-05-22 15:49:26 +01:00
Miss Islington (bot)
6d0850c4c8
gh-118486: Simplify test_win32_mkdir_700 to check the exact ACL (GH-119056)
(cherry picked from commit 94591dca51)

Co-authored-by: Steve Dower <steve.dower@python.org>
2024-05-15 11:21:57 +00:00
Miss Islington (bot)
5bf7f5c6a8
[3.12] gh-118998: Handle errors correctly in tmtotuple in timemodule (GH-118999) (#119019)
gh-118998: Handle errors correctly in `tmtotuple` in `timemodule` (GH-118999)
(cherry picked from commit fc75792594)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2024-05-13 21:47:12 +00:00
Steve Dower
eb29e2f590
gh-118486: Support mkdir(mode=0o700) on Windows (GH-118488) 2024-05-09 19:18:56 +01:00
Miss Islington (bot)
656491783d
[3.12] gh-118671: Updated dead ActiveState links (GH-118730) (#118754)
Co-authored-by: trag1c <trag1cdev@yahoo.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
2024-05-08 07:22:35 +00:00
Miss Islington (bot)
56c61cc564
[3.12] gh-118314: Fix padding edge case in binascii.a2b_base64 strict mode (GH-118320) (GH-118691)
gh-118314: Fix padding edge case in binascii.a2b_base64 strict mode (GH-118320)

Fix an edge case in `binascii.a2b_base64` strict mode, where
excessive padding was not detected when no padding is necessary.

(cherry picked from commit fe47d9bee3)

Co-authored-by: Youfu Zhang <1315097+zhangyoufu@users.noreply.github.com>
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
2024-05-07 09:35:49 +00:00
Serhiy Storchaka
bee1c322c0
[3.12] gh-71592: Add ability to trace Tcl commands executed by Tkinter (GH-118291) (GH-118662)
This is an experimental feature, for internal use.

Setting tkinter._debug = True before creating the root window enables
printing every executed Tcl command (or a Tcl command equivalent to the
used Tcl C API).

This will help to convert a Tkinter example into Tcl script to check
whether the issue is caused by Tkinter or exists in the underlying Tcl/Tk
library.
(cherry picked from commit 1ff626ebda)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-05-06 19:26:08 +00:00
Miss Islington (bot)
33d1cfffe1
[3.12] gh-117968: Make the test for closed file more safe in the C API tests (GH-118230) (GH-118266)
The behavior of fileno() after fclose() is undefined, but it is the only
practical way to check whether the file was closed.
Only test this on the known platforms (Linux, Windows, macOS), where we
already tested that it works.
(cherry picked from commit 546cbcfa0e)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-04-25 05:16:43 +00:00
Miss Islington (bot)
30725f0ad2
[3.12] gh-116741: Upgrade libexpat to 2.6.2 (GH-117296) (GH-118166)
gh-116741: Upgrade libexpat to 2.6.2 (GH-117296)

Upgrade libexpat to 2.6.2
(cherry picked from commit c9829eec08)

Co-authored-by: Seth Michael Larson <seth@python.org>
2024-04-23 01:30:59 +00:00
Serhiy Storchaka
8ae70c8761
[3.12] gh-117968: Add tests for the part of the PyRun family of the C API (GH-117982) (GH-118011)
(cherry picked from commit 6078f2033e)

Co-authored-by: NGRsoftlab <78017794+NGRsoftlab@users.noreply.github.com>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2024-04-22 18:59:28 +00:00
Miss Islington (bot)
9ddaf75a4c
[3.12] gh-117995: Don't raise DeprecationWarnings for indexed nameless params (GH-118001) (#118142)
Filter out '?NNN' placeholders when looking for named params.

(cherry picked from commit 550483b7e6)

Co-authored-by: Erlend E. Aasland <erlend@python.org>
Co-authored-by: AN Long <aisk@users.noreply.github.com>
2024-04-22 06:58:41 +00:00
Miss Islington (bot)
23192aba20
[3.12] GH-115874: Fix segfault in FutureIter_dealloc (GH-118114)
GH-115874: Fix segfault in FutureIter_dealloc (GH-117741)
(cherry picked from commit d8f350309d)

Co-authored-by: Savannah Ostrowski <savannahostrowski@gmail.com>
2024-04-19 22:53:18 +00:00
Miss Islington (bot)
6584ad9aa7
[3.12] gh-88035: update doc-string of epoch in timemodule.c (GH-118076) (GH-118097)
Follow GH-88035, update doc-string of epoch in timemodule.c

The epoch is `January 1st, 1970 on all platforms`, according to
current documentation.
(cherry picked from commit 7c6cc00211)

Co-authored-by: lit <litlighilit@foxmail.com>
2024-04-19 11:44:59 +00:00
Steve Dower
1a45659064
gh-90329: Add _winapi.GetLongPathName and GetShortPathName and use in venv to reduce warnings (GH-117817) 2024-04-15 16:43:41 +01:00
Miss Islington (bot)
50b94b150e
[3.12] gh-117694: Improve tests for PyEval_EvalCodeEx() (GH-117695) (GH-117884)
(cherry picked from commit 57bdb75975)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-04-15 10:02:43 +00:00
Miss Islington (bot)
0b11f0ef4f
[3.12] gh-117764: Add signatures for functions in the faulthandler module (GH-117771) (GH-117806)
(cherry picked from commit 245e426b55)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-04-12 10:48:55 +00:00
Miss Islington (bot)
9376a9f0d8
[3.12] gh-117233: Detect support for several hashes at hashlib build time (GH-117234) (#117767)
gh-117233: Detect support for several hashes at hashlib build time (GH-117234)

Detect libcrypto BLAKE2, Shake, SHA3, and Truncated-SHA512 support at hashlib build time

GH-GH- BLAKE2

While OpenSSL supports both "b" and "s" variants of the BLAKE2 hash
function, other cryptographic libraries may lack support for one or both
of the variants. This commit modifies `hashlib`'s C code to detect
whether or not the linked libcrypto supports each BLAKE2 variant, and
elides references to each variant's NID accordingly. In cases where the
underlying libcrypto doesn't fully support BLAKE2, CPython's
`./configure` script can be given the following flag to use CPython's
interned BLAKE2 implementation: `--with-builtin-hashlib-hashes=blake2`.

GH-GH- SHA3, Shake, & truncated SHA512.

Detect BLAKE2, SHA3, Shake, & truncated SHA512 support in the
OpenSSL-ish libcrypto library at build time.  This helps allow hashlib's
`_hashopenssl` to be used with libraries that do not to support every
algorithm that upstream OpenSSL does.  Such as AWS-LC & BoringSSL.

(cherry picked from commit b8eaad3009)

Co-authored-by: Will Childs-Klein <willck93@gmail.com>
Co-authored-by: Gregory P. Smith [Google LLC] <greg@krypto.org>
2024-04-11 18:36:31 +00:00
Miss Islington (bot)
af034dd150
[3.12] gh-117534: Add checking for input parameter in iso_to_ymd (GH-117543) (#117689)
gh-117534: Add checking for input parameter in iso_to_ymd (GH-117543)

Moves the validation for invalid years in the C implementation of the `datetime` module into a common location between `fromisoformat` and `fromisocalendar`, which improves the error message and fixes a failed assertion when parsing invalid ISO 8601 years using one of the "ISO weeks" formats.

---------

(cherry picked from commit d5f1139c79)

Co-authored-by: Vlad4896 <166005126+Vlad4896@users.noreply.github.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2024-04-09 18:17:21 +00:00
Miss Islington (bot)
eca377f203
gh-117267: Ensure DirEntry.stat().st_ctime still contains creation time during deprecation period (GH-117354)
(cherry picked from commit 985917dc8d)

Co-authored-by: Steve Dower <steve.dower@python.org>
2024-04-03 22:32:09 +00:00
Miss Islington (bot)
06ba6c86d2
[3.12] gh-91565: Update issue tracker URL in error message. (GH-117450) (#117497)
gh-91565: Update issue tracker URL in error message. (GH-117450)

* Update issue tracker URL in commit message.

* Also update issue tracker URL in comment.
(cherry picked from commit 8987a5c809)

Co-authored-by: Ezio Melotti <ezio.melotti@gmail.com>
2024-04-03 11:10:12 +02:00
Miss Islington (bot)
5a6318f2aa
[3.12] gh-117310: Remove extra DECREF on "no ciphers" error path in _ssl._SSLContext constructor (GH-117309) (GH-117317)
gh-117310: Remove extra DECREF on "no ciphers" error path in `_ssl._SSLContext` constructor (GH-117309)

Remove extra self DECREF on ssl "no ciphers" error path.

This doesn't come up in practice because nobody links against a broken
OpenSSL library that provides nothing.
(cherry picked from commit 8cb7d7ff86)

Co-authored-by: Gregory P. Smith <greg@krypto.org>
2024-03-28 10:04:57 -07:00
Gregory P. Smith
2f9caafdf4
[3.12] gh-99108: Refresh HACL*; update modules accordingly; fix namespacing (GH-117237) (GH-117243)
Pulls in a new update from https://github.com/hacl-star/hacl-star and fixes our C "namespacing" done by `Modules/_hacl/refresh.sh`.

Co-authored-by: Jonathan Protzenko <protz@microsoft.com>
2024-03-26 01:43:24 +00:00
Miss Islington (bot)
bd2c60f8c2
[3.12] gh-91227: Ignore ERROR_PORT_UNREACHABLE in proactor recvfrom() (GH-32011) (GH-117209)
(cherry picked from commit f11d0d8be8)

Co-authored-by: Erik Soma <stillusingirc@gmail.com>
2024-03-25 12:21:31 +02:00
jkriegshauser
d69c51520e
[3.12] gh-116773: Fix overlapped memory corruption crash (GH-116774) (#117078)
Manual backport of gh-116774.
2024-03-20 13:10:15 -07:00
Serhiy Storchaka
da2f9d1417
[3.12] gh-117021: Fix integer overflow in PyLong_AsPid() on non-Windows 64-bit platforms (GH-117064) (GH-117070)
(cherry picked from commit 519b2ae22b)
2024-03-20 16:44:05 +02:00
Sam Gross
92564331de
[3.12] gh-113964: Don't prevent new threads until all non-daemon threads exit (GH-116677) (#117029)
Starting in Python 3.12, we prevented calling fork() and starting new threads
during interpreter finalization (shutdown). This has led to a number of
regressions and flaky tests. We should not prevent starting new threads
(or `fork()`) until all non-daemon threads exit and finalization starts in
earnest.

This changes the checks to use `_PyInterpreterState_GetFinalizing(interp)`,
which is set immediately before terminating non-daemon threads.

(cherry picked from commit 60e105c1c1)
2024-03-19 15:22:42 -04:00
Miss Islington (bot)
1c0c6c91af
[3.12] gh-115874: Don't use module state in teedataobject tp_dealloc (GH-116204) (#116955)
(cherry picked from commit e2fcaf19d3)

Co-authored-by: Erlend E. Aasland <erlend@python.org>
Co-authored-by: Brandt Bucher <brandtbucher@microsoft.com>
2024-03-18 12:40:34 +00:00
Antoine Pitrou
fcb230180f
[3.12] gh-112536: Add --tsan test for reasonable TSAN execution times. (gh-116601) (#116929)
(cherry picked from commit ebf29b3)

Co-authored-by: Donghee Na <donghee.na@python.org>
2024-03-18 10:22:19 +01:00