Commit Graph

12916 Commits

Author SHA1 Message Date
Serhiy Storchaka dbe416b82b
[3.11] gh-106033: Get rid of new occurrences of PyDict_GetItem and Py… (#106040)
[3.11] gh-106033: Get rid of new occurrences of PyDict_GetItem and PyObject_HasAttr (GH-106034)

These functions are broken by design because they discard any exceptions raised
inside, including MemoryError and KeyboardInterrupt.  They should not be
used in new code..
(cherry picked from commit 1d33d53780)
2023-06-24 16:41:02 -07:00
Erlend E. Aasland 2b1745f37c
[3.11] gh-105375: Improve error handling in _Unpickler_SetInputStream() (#105667) (#105721)
Prevent exceptions from possibly being overwritten in case of multiple
failures.

(cherry picked from commit 217589d4f3)
2023-06-13 09:07:20 +00:00
Erlend E. Aasland 36c393c044
[3.11] gh-105375: Explicitly initialise all {Pickler,Unpickler}Object fields (#105686) (#105711)
* [3.11] gh-105375: Explicitly initialise all {Pickler,Unpickler}Object fields (#105686)

All fields must be explicitly initialised to prevent manipulation of
uninitialised fields in dealloc.

Align initialisation order with the layout of the object structs.

(cherry picked from commit ca3cc4b95d)

Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2023-06-13 06:50:00 +00:00
Miss Islington (bot) 261d0b4f0e
[3.11] gh-105436: The environment block should end with two null wchar_t values (GH-105495) (#105701)
gh-105436: The environment block should end with two null wchar_t values (GH-105495)
(cherry picked from commit 4f7d3b602d)

Co-authored-by: Dora203 <66343334+sku2000@users.noreply.github.com>
2023-06-12 16:49:57 +00:00
Erlend E. Aasland e5fe017143
[3.11] gh-105375: Harden pyexpat initialisation (#105606) (#105668)
(cherry picked from commit 20a56d8bec)

Add proper error handling to add_errors_module() to prevent exceptions
from possibly being overwritten.
2023-06-11 21:28:12 +00:00
Miss Islington (bot) a03449374e
[3.11] gh-105375: Improve error handling in _ctypes (GH-105593) (#105664)
Prevent repeated PyLong_FromVoidPtr() from possibly overwriting the
current exception.
(cherry picked from commit e8998e46a7)

Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2023-06-11 20:30:47 +00:00
Erlend E. Aasland 87e493b11a
[3.11] gh-105375: Harden _ssl initialisation (#105599) (#105651)
(cherry picked from commit 01f4230460)

Add proper error handling to prevent reference leaks and overwritten
exceptions.

Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2023-06-11 21:25:36 +02:00
Miss Islington (bot) cb26fafdcc
[3.11] gh-105375: Improve _decimal error handling (GH-105605) (#105648)
Fix a bug where an exception could end up being overwritten.
(cherry picked from commit c932f72849)

Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2023-06-11 10:58:56 +00:00
Miss Islington (bot) cfa0f7c59b
[3.11] gh-105375: Harden _datetime initialisation (GH-105604) (#105646)
Improve error handling so init bails on the first exception.
(cherry picked from commit 16d49680b5)

Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2023-06-11 10:41:37 +00:00
Miss Islington (bot) 3c08e54ccf
[3.11] gh-105375: Improve array.array exception handling (GH-105594) (#105643)
Fix a bug where 'tp_richcompare' could end up overwriting an exception.
(cherry picked from commit 35cff545db)

Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2023-06-11 10:22:31 +00:00
Miss Islington (bot) 4ceb5c4924
[3.11] gh-105375: Improve error handling in `zoneinfo` module (GH-105586) (#105613)
Fix bugs where exceptions could end up being overwritten
because of deferred error handling.

(cherry picked from commit 33c92c4f15)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2023-06-09 22:54:00 +00:00
Miss Islington (bot) e4748628e1
[3.11] gh-105375: Improve error handling in _elementtree (GH-105591) (#105601)
Fix bugs where exceptions could end up being overwritten.
(cherry picked from commit 00b599ab5a)

Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2023-06-09 21:19:59 +00:00
Miss Islington (bot) c1797f661d
[3.11] gh-105375: Improve posix error handling (GH-105592) (#105597)
Fix a bug where an IndexError could end up being overwritten.
(cherry picked from commit f668f73bc8)

Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2023-06-09 20:55:34 +00:00
Erlend E. Aasland 76682ba7af
[3.11] gh-105375: Improve errnomodule error handling (#105590) (#105595)
(cherry picked from commit eede1d2f48)

Bail immediately if an exception is set, to prevent exceptions from
being overwritten.
2023-06-09 20:35:30 +00:00
Erlend E. Aasland 4d4251d6ec
[3.11] gh-105375: Improve _pickle error handling (#105475) (#105583)
(cherry picked from commit 89aac6f6b7)

Error handling was deferred in some cases, which could potentially lead
to exceptions being overwritten.
2023-06-09 17:56:02 +00:00
Miss Islington (bot) 571ec56b65
[3.11] gh-105375: Improve error handling in sqlite3 collation callback (GH-105412) (#105441)
Check for error after each call to PyUnicode_FromStringAndSize().
(cherry picked from commit a24a780d93)

Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2023-06-07 21:22:01 +00:00
Miss Islington (bot) c644fe403a
[3.11] gh-104399: Use newer libtommath APIs when necessary (GH-104407) (#105344)
gh-104399: Use newer libtommath APIs when necessary (GH-104407)
(cherry picked from commit 00d73caf80)

Co-authored-by: Christopher Chavez <chrischavez@gmx.us>
2023-06-06 10:01:54 -04:00
Gregory P. Smith a5d2b546c1
[3.11] gh-103142: Upgrade binary builds and CI to OpenSSL 1.1.1u (GH-105174) (#105200)
Upgrade builds to OpenSSL 1.1.1u.

This OpenSSL version addresses a pile if less-urgent CVEs since 1.1.1t.

The Mac/BuildScript/build-installer.py was already updated.

Also updates _ssl_data_111.h from OpenSSL 1.1.1u, _ssl_data_300.h from 3.0.9.

Manual edits to the _ssl_data_300.h file prevent it from removing any existing definitions in case those exist in some peoples builds and were important (avoiding regressions during backporting).

(cherry picked from commit ede89af)
2023-06-01 18:07:53 +00:00
Gregory P. Smith 6d00ae3c28
[3.11] gh-104372: Cleanup _posixsubprocess make_inheritable for async signal safety gh-104518 (#104785)
Move all of the Python C API calls into the parent process up front
instead of doing PyLong_AsLong and PyErr_Occurred and PyTuple_GET from
the post-fork/vfork child process.

Much of this was long overdue. We shouldn't have been using PyTuple and
PyLong APIs within all of these low level functions anyways.

This is a backport of c649df6 for #104518 and the tiny adjustment in d1732fe #104697.

Backporting this allows backporting of the real bug fix that requires it.

Co-authored-by: Gregory P. Smith [Google] <greg@krypto.org>
2023-05-23 20:42:25 -07:00
Miss Islington (bot) 1692a16a25
[3.11] Add IPv6 into to the docstring for socket.getsockname (GH-102961) (#103137)
Add IPv6 into to the docstring for socket.getsockname (GH-102961)
(cherry picked from commit ecc5441505)

Signed-off-by: Brian Haley <haleyb.dev@gmail.com>
Co-authored-by: Brian Haley <brianphaley@gmail.com>
2023-05-22 12:46:45 +02:00
Miss Islington (bot) b2e0201222
[3.11] gh-104698: Fix reference leak in mmapmodule.c (GH-104700) (#104710)
(cherry picked from commit 99b641886a)

Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-05-20 18:43:18 -07:00
Miss Islington (bot) 2e457bc202
[3.11] gh-101857: Allow xattr detection on musl libc (GH-101858) (#101894)
gh-101857: Allow xattr detection on musl libc (GH-101858)

Previously, we checked exclusively for `__GLIBC__` (AND'd with some other
conditions). Checking for `__linux__` instead should be fine.

This fixes using e.g. `os.listxattr()` on systems using musl libc.

Bug: https://bugs.gentoo.org/894130

(cherry picked from commit 8be8101bca)

Co-authored-by: Sam James <sam@gentoo.org>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-05-21 00:17:27 +00:00
Miss Islington (bot) dbb011afae
[3.11] gh-103987: fix several crashes in mmap module (GH-103990) (#104677)
gh-103987: fix several crashes in mmap module (GH-103990)
(cherry picked from commit ceaa4c3476)

Co-authored-by: Prince Roshan <princekrroshan01@gmail.com>
Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-05-20 03:59:54 +00:00
Mark Shannon 7b3bc95067
[3.11] GH-102818: Do not call PyTraceBack_Here in sys.settrace trampoline (GH-104650)
Backport of GH-104579
2023-05-19 19:08:43 +01:00
Miss Islington (bot) d78c3bcf6f
[3.11] gh-104645: fix error handling in marshal tests (GH-104646) (#104663)
gh-104645: fix error handling in marshal tests (GH-104646)
(cherry picked from commit ac56a854b4)

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
2023-05-19 16:46:37 +00:00
Miss Islington (bot) b7622e7a05
[3.11] GH-104308: socket.getnameinfo should release the GIL (GH-104307) (#104313)
GH-104308: socket.getnameinfo should release the GIL (GH-104307)

* socket.getnameinfo should release the GIL

* 📜🤖 Added by blurb_it.

---------

(cherry picked from commit faf196213e)

Co-authored-by: Nathaniel J. Smith <njs@pobox.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2023-05-08 23:49:45 +00:00
Miss Islington (bot) 065e2ae99a
[3.11] gh-104265 Disallow instantiation of `_csv.Reader` and `_csv.Writer` (GH-104266) (#104278)
gh-104265 Disallow instantiation of `_csv.Reader` and `_csv.Writer` (GH-104266)
(cherry picked from commit 06c2a4858b)

Co-authored-by: chgnrdv <52372310+chgnrdv@users.noreply.github.com>
2023-05-08 17:34:43 +05:30
Erlend E. Aasland 681d5028bd
[3.11] gh-100370: fix OverflowError in sqlite3.Connection.blobopen for 32-bit builds (#103902) (#104285) 2023-05-08 08:41:34 +00:00
Dong-hee Na 81902d3ed3
[3.11] gh-104106: Add gcc fallback of mkfifoat/mknodat for macOS (gh-104129) (gh-104187)
gh-104106: Add gcc fallback of mkfifoat/mknodat for macOS (gh-104129)
2023-05-05 04:32:28 +00:00
Miss Islington (bot) 4fa5fda14b
gh-103242: Migrate SSLContext.set_ecdh_curve not to use deprecated APIs (GH-103378)
Migrate `SSLContext.set_ecdh_curve()` not to use deprecated OpenSSL APIs.
(cherry picked from commit 35167043e3)

Co-authored-by: Dong-hee Na <donghee.na@python.org>
2023-04-08 11:21:27 -07:00
Miss Islington (bot) 8740fd855c
gh-103256: Fix hmac algorithm to support fallback implementation (gh-103286)
(cherry picked from commit efb0a2cf3a)

Co-authored-by: Dong-hee Na <donghee.na@python.org>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-04-06 19:27:46 -07:00
Miss Islington (bot) 13df5d3497
[3.11] GH-95494: Fix transport EOF handling in OpenSSL 3.0 (GH-95495) (#103006)
GH-25309 enabled SSL_OP_IGNORE_UNEXPECTED_EOF by default, with a comment
that it restores OpenSSL 1.1.1 behavior, but this wasn't quite right.
That option causes OpenSSL to treat transport EOF as the same as
close_notify (i.e. SSL_ERROR_ZERO_RETURN), whereas Python actually has
distinct SSLEOFError and SSLZeroReturnError exceptions. (The latter is
usually mapped to a zero return from read.) In OpenSSL 1.1.1, the ssl
module would raise them for transport EOF and close_notify,
respectively. In OpenSSL 3.0, both act like close_notify.

Fix this by, instead, just detecting SSL_R_UNEXPECTED_EOF_WHILE_READING
and mapping that to the other exception type.

There doesn't seem to have been any unit test of this error, so fill in
the missing one. This had to be done with the BIO path because it's
actually slightly tricky to simulate a transport EOF with Python's fd
based APIs. (If you instruct the server to close the socket, it gets
confused, probably because the server's SSL object is still referencing
the now dead fd?)
(cherry picked from commit 420bbb783b)

Co-authored-by: David Benjamin <davidben@google.com>
2023-03-27 16:14:01 +02:00
Max Bachmann b28f919007
[3.11] gh-102281: Fix potential nullptr dereference + use of uninitia… (#103040)
[3.11] gh-102281: Fix potential nullptr dereference + use of uninitialized memory (gh-102282)
(cherry picked from commit afa6092ee4)
2023-03-25 16:35:00 -07:00
Miss Islington (bot) 67161396de
[3.11] gh-102027: Fix macro name (GH-102124) (#102916)
gh-102027: Fix macro name (GH-102124)

This fixes the ssse3 / sse2 detection when sse4 is available.

(cherry picked from commit ea93bde4ec)

Co-authored-by: Max Bachmann <kontakt@maxbachmann.de>
Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
2023-03-24 13:40:22 +01:00
Miss Islington (bot) e075631f67
[3.11] gh-96931: Fix incorrect results in ssl.SSLSocket.shared_ciphers (GH-96932) (#102918)
gh-96931: Fix incorrect results in ssl.SSLSocket.shared_ciphers (GH-96932)
(cherry picked from commit af9c34f6ef)

Co-authored-by: Benjamin Fogle <benfogle@gmail.com>
2023-03-24 13:33:24 +01:00
Miss Islington (bot) fd43fb6996
GH-100989: remove annotation from docstring (GH-102991)
(cherry picked from commit d49409196e)

Co-authored-by: Raymond Hettinger <rhettinger@users.noreply.github.com>
2023-03-23 23:04:06 -07:00
Miss Islington (bot) a4a039c546
GH-100989: Revert Improve the accuracy of collections.deque docstrings (GH-102979)
(cherry picked from commit 7f01a11199)

Co-authored-by: Raymond Hettinger <rhettinger@users.noreply.github.com>
2023-03-23 18:17:43 -07:00
Miss Islington (bot) f7dea0cb32
gh-100989: Improve the accuracy of collections.deque docstrings (GH-100990)
(cherry picked from commit c74073657e)

Co-authored-by: Timo Ludwig <ti.ludwig@web.de>
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
2023-03-22 05:25:03 -07:00
Irit Katriel fcafc37411
[3.11] gh-102493: backport unit test for PyErr_SetObject (#102602)
gh-102493: backport unit test for PyErr_SetObject
2023-03-11 15:01:01 +00:00
Miss Islington (bot) 7905ae7b1a
GH-102397: Fix segfault from race condition in signal handling (GH-102399)
(cherry picked from commit 1a84cc007e)

Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-03-08 00:26:20 -08:00
Miss Islington (bot) cc6ce90206
gh-102179: Fix `os.dup2` error reporting for negative fds (GH-102180)
(cherry picked from commit c2bd55d26f)

Co-authored-by: Alexey Izbyshev <izbyshev@ispras.ru>
2023-03-04 06:55:02 -08:00
Mark Dickinson eb5565918a
[3.11] Add missing 'is' to `cmath.log()` docstring (GH-102049) (#102279)
Fix missing 'is' in cmath.log() docstring.
(cherry picked from commit 71f614ef2a)

Co-authored-by: Owain Davies <116417456+OTheDev@users.noreply.github.com>
2023-02-26 14:55:44 +00:00
Nikita Sobolev d0ff3d996f
[3.11] gh-101656: Fix "conversion from Py_ssize_t to int" warning in `_testcapimodule` (#101680)
(cherry picked from commit acc2f3b19d)
2023-02-08 11:02:07 +01:00
Łukasz Langa 955ba2839b
[3.11] gh-101072: support default and kw default in PyEval_EvalCodeEx for 3.11+ (GH-101127) (#101636)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Matthieu Dartiailh <m.dartiailh@gmail.com>
2023-02-07 13:36:35 +00:00
Miss Islington (bot) d003bcc91a
gh-101543: Ensure Windows registry path is only used when stdlib can't be found (GH-101544)
(cherry picked from commit 7a253103d4)

Co-authored-by: Steve Dower <steve.dower@python.org>
2023-02-06 09:34:05 -08:00
Miss Islington (bot) 9bd000c7b8
gh-101372: Fix unicodedata.is_normalized to properly handle the UCD 3… (gh-101388)
(cherry picked from commit 9ef7e75434)

Co-authored-by: Dong-hee Na <donghee.na@python.org>
2023-02-06 02:32:30 -08:00
Gregory P. Smith fa7c37af49
[3.11] gh-99952: fix refcount issues in ctypes.Structure from_param() result (#101339)
[3.11] gh-99952: [ctypes] fix refcount issues in from_param() result. (GH-100169)

Fixes a reference counting issue with `ctypes.Structure` when a `from_param()` method call is used and the structure size is larger than a C pointer `sizeof(void*)`.

This problem existed for a very long time, but became more apparent in 3.8+ by change likely due to garbage collection cleanup timing changes..
(cherry picked from commit dfad678d70)

Co-authored-by: Yukihiro Nakadaira <yukihiro.nakadaira@gmail.com>
2023-01-26 01:02:37 -08:00
Shantanu cd0fe5ba09
[3.11] gh-101326: Fix regression when passing None to FutureIter.throw (GH-101327) (#101328)
(cherry picked from commit a178ba82bf)

Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
2023-01-25 13:01:13 -08:00
Miss Islington (bot) 5964b12829
gh-100795: Don't call freeaddrinfo on failure. (GH-101252)
When getaddrinfo returns an error, the output pointer is in an unknown state
Don't call freeaddrinfo on it.  See the issue for discussion and details with
links to reasoning.  _Most_ libc getaddrinfo implementations never modify the
output pointer unless they are returning success.

(cherry picked from commit b724ac2fe7)

Co-authored-by: Gregory P. Smith <greg@krypto.org>
Co-authored-by: Sergey G. Brester <github@sebres.de>
Co-authored-by: Oleg Iarygin <dralife@yandex.ru>
2023-01-23 15:30:19 -08:00
Miss Islington (bot) 3ef9f6b508
gh-82052: Don't send partial UTF-8 sequences to the Windows API (GH-101103)
Don't send partial UTF-8 sequences to the Windows API
(cherry picked from commit f34176b77f)

Co-authored-by: Paul Moore <p.f.moore@gmail.com>
2023-01-17 11:52:50 -08:00