Commit graph

13506 commits

Author SHA1 Message Date
Miss Islington (bot)
748bc48648
[3.12] gh-108082: C API: Add tests for PyErr_WriteUnraisable() (GH-111455) (GH-111507)
Also document the behavior when called with NULL.
(cherry picked from commit bca3305429)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-10-30 17:36:00 +00:00
Miss Islington (bot)
c3f75b757f
[3.12] gh-111342: fix typo in math.sumprod (GH-111416) (gh-111419) 2023-10-28 05:27:33 +00:00
Miss Islington (bot)
e25d8b40cd
GH-111293: Fix DirEntry.inode dropping higher bits on Windows (GH-111294)
(cherry picked from commit b468538d35)

Co-authored-by: zcxsythenew <30565051+zcxsythenew@users.noreply.github.com>
2023-10-26 17:08:41 +00:00
Miss Islington (bot)
45c0b38880
[3.12] gh-111174: Fix crash in getbuffer() called repeatedly for empty BytesIO (GH-111210) (GH-111314)
(cherry picked from commit 9da98c0d9a)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-10-25 11:25:31 +00:00
Serhiy Storchaka
54e93d36d0
[3.12] gh-111065: Add more tests for the C API with the PySys_ prefix (GH-111067) (GH-111305)
* Move existing tests for PySys_GetObject() and PySys_SetObject() into
  specialized files.
* Add test for PySys_GetXOptions() using _testcapi.
* Add tests for PySys_FormatStdout(), PySys_FormatStderr(),
  PySys_WriteStdout() and PySys_WriteStderr() using ctypes.

(cherry picked from commit b2ba298527)
2023-10-25 09:10:03 +00:00
Miss Islington (bot)
552ceb2d0f
[3.12] gh-110572: Fix potential leaks in test_*_code in _testcapi/getargs.c (GH-110573) (GH-111161)
(cherry picked from commit f71cd5394e)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2023-10-21 12:57:22 +00:00
Miss Islington (bot)
dfc8d7ac93
gh-110913: Fix WindowsConsoleIO chunking of UTF-8 text (GH-111007)
(cherry picked from commit 11312eae6e)

Co-authored-by: Tamás Hegedűs <sorgloomer@users.noreply.github.com>
2023-10-20 12:37:31 +00:00
Serhiy Storchaka
72b0f0eaf5
[3.12] bpo-42663: Fix parsing TZ strings in zoneinfo module (GH-23825) (GH-110882)
zipinfo now supports the full range of values in the TZ string
determined by RFC 8536 and detects all invalid formats.
Both Python and C implementations now raise exceptions of the same
type on invalid data.
(cherry picked from commit ab08ff7882)
2023-10-15 10:59:19 +03:00
Serhiy Storchaka
7c3e8e5af0
[3.12] gh-110628: Add tests for PyLong C API (GH-110629) (GH-110854)
(cherry picked from commit 9d40ebf190)
2023-10-14 10:20:24 +03:00
Miss Islington (bot)
a2cc9a4c3a
[3.12] gh-109747: Improve errors for unsupported look-behind patterns (GH-109859) (GH-110859)
Now re.error is raised instead of OverflowError or RuntimeError for
too large width of look-behind pattern.

The limit is increased to 2**32-1 (was 2**31-1).
(cherry picked from commit e2b3d831fd)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-10-14 06:42:19 +00:00
Miss Islington (bot)
1c44f881c7
[3.12] gh-110815: Improve tests for PyArg_ParseTupleAndKeywords() (GH-110817) (GH-110825)
(cherry picked from commit 548ce0923b)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-10-13 13:41:43 +00:00
Miss Islington (bot)
ca971d12ed
[3.12] gh-84489: C API: Add tests for Py_BuildValue() (GH-110596) (GH-110680)
(cherry picked from commit 5c6e85480a)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-10-11 11:12:39 +03:00
Miss Islington (bot)
c1e8e90915
[3.12] gh-110590: Fix a bug where _sre.compile would overwrite exceptions (GH-110591) (#110613)
TypeError would be overwritten by OverflowError
if 'code' param contained non-ints.
(cherry picked from commit 344d3a222a)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2023-10-10 10:55:21 +00:00
Miss Islington (bot)
190660abe9
[3.12] gh-78469: Declare missing sethostname for Solaris 10 (GH-109447) (#110580)
Add OS version specific macro for Solaris: Py_SUNOS_VERSION.
(cherry picked from commit 3b1580af07)

Co-authored-by: Jakub Kulík <Kulikjak@gmail.com>
2023-10-10 09:26:36 +00:00
Miss Islington (bot)
53122bcf82
[3.12] gh-109191: Fix build with newer editline (gh-110239) (gh-110562)
gh-109191: Fix build with newer editline (gh-110239)
(cherry picked from commit f4cb0d27cc)

Co-authored-by: Bo Anderson <mail@boanderson.me>
2023-10-09 23:01:00 +09:00
Serhiy Storchaka
5afac0cf8d
[3.12] gh-110549: Remove unused includes of <stddef.h> in _testcapi (GH-110552) (GH-110553)
(cherry picked from commit 89df5b73d0)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2023-10-09 11:43:35 +00:00
Miss Islington (bot)
b2419eff95
[3.12] gh-110525: Cover PySet_Add corner case with frozenset objects (GH-110544) (GH-110554)
(cherry picked from commit ea39c877c0)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2023-10-09 11:40:53 +00:00
Nikita Sobolev
3ed5cb0de3
[3.12] gh-110525: Add CAPI tests for set and frozenset objects (GH-110526). (GH-110547)
(cherry picked from commit c49edd7d9c)
2023-10-09 10:04:09 +00:00
Miss Islington (bot)
7bfcfcf656
[3.12] gh-110365: Fix error overwrite in termios.tcsetattr (GH-110366) (#110389)
(cherry picked from commit 2bbbab212f)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Erlend E. Aasland <erlend@python.org>
2023-10-05 14:21:03 +02:00
Victor Stinner
4936fa9541
[3.12] gh-108987: Fix _thread.start_new_thread() race condition (#109135) (#110342)
* gh-108987: Fix _thread.start_new_thread() race condition (#109135)

Fix _thread.start_new_thread() race condition. If a thread is created
during Python finalization, the newly spawned thread now exits
immediately instead of trying to access freed memory and lead to a
crash.

thread_run() calls PyEval_AcquireThread() which checks if the thread
must exit. The problem was that tstate was dereferenced earlier in
_PyThreadState_Bind() which leads to a crash most of the time.

Move _PyThreadState_CheckConsistency() from thread_run() to
_PyThreadState_Bind().

(cherry picked from commit 517cd82ea7)

* gh-109795: `_thread.start_new_thread`: allocate thread bootstate using raw memory allocator (#109808)

(cherry picked from commit 1b8f2366b3)

---------

Co-authored-by: Radislav Chugunov <52372310+chgnrdv@users.noreply.github.com>
2023-10-04 11:20:31 +00:00
Miss Islington (bot)
892b1942a7
[3.12] gh-110241: Add missing error check to record_eval in _testinternalcapi (GH-110242) (#110244)
gh-110241: Add missing error check to `record_eval` in `_testinternalcapi` (GH-110242)
(cherry picked from commit 4596c76d1a)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2023-10-02 21:38:25 +00:00
Alex Waygood
da75bd6c31
[3.12] gh-109782: Ensure os.path.isdir has the same signature on all platforms (GH-109790) (#110233)
gh-109782: Ensure `os.path.isdir` has the same signature on all platforms (GH-109790)

Co-authored-by: Amin Alaee <mohammadamin.alaee@gmail.com>
2023-10-02 19:25:06 +00:00
Victor Stinner
d0641ab676
[3.12] gh-110052: Fix faulthandler for freed tstate (#110069) (#110071)
gh-110052: Fix faulthandler for freed tstate (#110069)

faulthandler now detected freed interp and freed tstate, and no
longer dereference them.

(cherry picked from commit 2e37a38bcb)
2023-10-02 17:44:51 +02:00
Miss Islington (bot)
95fd4edc63
[3.12] gh-109098: Fuzz re module instead of internal sre (GH-109911) (#109932)
gh-109098: Fuzz re module instead of internal sre (GH-109911)

* gh-109098: Fuzz re module instead of internal sre
* Fix c-analyzer globals test failure
* Put globals exception in ignored.tsv
(cherry picked from commit a829356f86)

Co-authored-by: Ammar Askar <ammar@ammaraskar.com>
2023-10-02 17:39:07 +02:00
Miss Islington (bot)
b723b8a13d
[3.12] gh-109593: Fix reentrancy issue in multiprocessing resource_tracker (GH-109629) (#109898)
gh-109593: Fix reentrancy issue in multiprocessing resource_tracker (GH-109629)

---------

(cherry picked from commit 0eb98837b6)

Co-authored-by: Antoine Pitrou <antoine@python.org>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2023-10-02 17:37:40 +02:00
Miss Islington (bot)
65c845e065
[3.12] gh-109631: Allow interruption of short repeated regex matches (GH-109867) (#109886)
gh-109631: Allow interruption of short repeated regex matches (GH-109867)

Counting for signal checking now continues in new match from the point where
it ended in the previous match instead of starting from 0.
(cherry picked from commit 8ac2085b80)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-10-02 17:36:29 +02:00
Miss Islington (bot)
47e96c6782
[3.12] gh-109613: _pystat_fromstructstat() checks for exceptions (GH-109618) (#109641)
gh-109613: _pystat_fromstructstat() checks for exceptions (GH-109618)

Fix os.stat() and os.DirEntry.stat(): check for exceptions.
Previously, on Python built in debug mode, these functions could
trigger a fatal Python error (and abort the process) when a function
succeeded with an exception set.

_pystat_fromstructstat() now exits immediately if an exception is
raised, rather only checking for exceptions at the end. It fix
following fatal error in fill_time():

    Fatal Python error: _Py_CheckSlotResult:
    Slot * of type int succeeded with an exception set
(cherry picked from commit d4cea794a7)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-10-02 17:09:45 +02:00
Miss Islington (bot)
ddc0adcdb3
[3.12] gh-109469: Silence compiler warnings on string comparisons in _testcapi (GH-109533) (#109558)
gh-109469: Silence compiler warnings on string comparisons in _testcapi (GH-109533)
(cherry picked from commit ed582a2ed9)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-10-02 16:59:43 +02:00
Victor Stinner
30748d36b3
[3.12] gh-104690: thread_run() checks for tstate dangling pointer (#109056) (#109133)
gh-104690: thread_run() checks for tstate dangling pointer (#109056)

thread_run() of _threadmodule.c now calls
_PyThreadState_CheckConsistency() to check if tstate is a dangling
pointer when Python is built in debug mode.

Rename ceval_gil.c is_tstate_valid() to
_PyThreadState_CheckConsistency() to reuse it in _threadmodule.c.

(cherry picked from commit f63d37877a)
2023-10-02 16:55:06 +02:00
Miss Islington (bot)
69a9f47125
[3.12] gh-110045: Update symtable module for PEP 695 (GH-110066) (#110070)
gh-110045: Update symtable module for PEP 695 (GH-110066)
(cherry picked from commit 7dc2c5093e)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-09-29 08:10:22 +02:00
Miss Islington (bot)
74a7f5d2da
[3.12] gh-109496: Detect Py_DECREF() after dealloc in debug mode (GH-109539) (#109545)
gh-109496: Detect Py_DECREF() after dealloc in debug mode (GH-109539)

On a Python built in debug mode, Py_DECREF() now calls
_Py_NegativeRefcount() if the object is a dangling pointer to
deallocated memory: memory filled with 0xDD "dead byte" by the debug
hook on memory allocators. The fix is to check the reference count
*before* checking for _Py_IsImmortal().

Add test_decref_freed_object() to test_capi.test_misc.
(cherry picked from commit 0bb0d88e2d)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-09-18 17:39:27 +00:00
Serhiy Storchaka
e65401d245
[3.12] C API tests: use special markers to test that output parameters were set (GH-109014) (#109023)
[3.12] C API tests: use special markers to test that output parameters were set (GH-109014).
(cherry picked from commit bf414b7fcb)
2023-09-08 15:09:49 +02:00
Łukasz Langa
e0f6080819
[3.12] gh-46376: Revert "Return existing pointer when possible in ctypes (GH-107131) (GH-107487)" (#108864)
This reverts commit 54aaaadef8.

Co-authored-by: T. Wouters <thomas@python.org>
2023-09-04 16:24:16 +02:00
Miss Islington (bot)
ba7e06bb63
[3.12] Add Modules/_testcapi/util.h header (GH-108774) (#108780)
Add Modules/_testcapi/util.h header (GH-108774)

It contains common macros used in C API tests.
(cherry picked from commit 0e01fac315)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-09-02 23:43:14 +02:00
Erlend E. Aasland
036dd6958a
[3.12] gh-107801: Improve the accuracy of io.IOBase.seek docs (#108268) (#108655)
(cherry picked from commit 8178a88bd8)

- Add param docstrings
- Link to os.SEEK_* constants
- Mention the return value in the initial paragraph

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2023-08-29 22:19:08 +02:00
Erlend E. Aasland
f90099c3bd
[3.12] gh-107801: Document io.TextIOWrapper.tell (#108265) (#108547)
(cherry picked from commit 38afa4af9b)
2023-08-28 01:59:48 +02:00
Miss Islington (bot)
07c0e24748
[3.12] Clarify distinction between datetime module and class in deprecation messages (GH-108073) (#108540)
Clarify distinction between datetime module and class in deprecation messages (GH-108073)
(cherry picked from commit 09343dba44)

Co-authored-by: Clément Robert <cr52@protonmail.com>
2023-08-27 16:16:21 +02:00
Miss Islington (bot)
3e20303717
[3.12] gh-107913: Fix possible losses of OSError error codes (GH-107930) (#108523)
gh-107913: Fix possible losses of OSError error codes (GH-107930)

Functions like PyErr_SetFromErrno() and SetFromWindowsErr() should be
called immediately after using the C API which sets errno or the Windows
error code.
(cherry picked from commit 2b15536fa9)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-08-27 01:24:40 +02:00
Erlend E. Aasland
ef4d427fd8
[3.12] gh-107801: Improve the accuracy of io.TextIOWrapper.seek docs (#107933) (#108262)
(cherry picked from commit 7f87ebbc3f)

Clearly document the supported seek() operations:

- Rewind to the start of the stream
- Restore a previous stream position (given by tell())
- Fast-forward to the end of the stream
2023-08-22 12:01:38 +02:00
Miss Islington (bot)
97d67e9dab
[3.12] gh-107915: Handle errors in C API functions PyErr_Set*() and PyErr_Format() (GH-107918) (#108134)
* gh-107915: Handle errors in C API functions PyErr_Set*() and PyErr_Format() (GH-107918)

Such C API functions as PyErr_SetString(), PyErr_Format(),
PyErr_SetFromErrnoWithFilename() and many others no longer crash or
ignore errors if it failed to format the error message or decode the
filename. Instead, they keep a corresponding error.
(cherry picked from commit 633ea217a8)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>

* Define PY_SSIZE_T_CLEAN.

---------

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-08-20 23:07:24 +02:00
Erlend E. Aasland
0c21298f2b
[3.12] gh-108083: Don't ignore exceptions in sqlite3.Connection.__init__() and .close() (#108084) (#108141)
- Add explanatory comments
- Add return value to connection_close() for propagating errors
- Always check the return value of connection_exec_stmt()
- Assert pre/post state in remove_callbacks()
- Don't log unraisable exceptions in case of interpreter shutdown
- Make sure we're not initialized if reinit fails
- Try to close the database even if ROLLBACK fails

(cherry picked from commit fd19509220)

Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-08-20 01:07:41 +02:00
Erlend E. Aasland
41634edb2b
[3.12] gh-107801: Improve the accuracy of os.lseek docs (#107935) (#108136)
- name the last parameter *whence*, like it is for seek() methods on
  file objects
- add param docstrings
- structure the valid *whence* params

(cherry picked from commit dd4442c8f5)

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2023-08-20 01:05:00 +02:00
Steve Dower
ede9895881
[3.12] gh-106242: Fix path truncation in os.path.normpath (GH-106816) (#107981)
* gh-106242: Fix path truncation in os.path.normpath (GH-106816)
* gh-106242: Minor fixup to avoid compiler warnings

---------

Co-authored-by: Finn Womack <flan313@gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-08-17 01:19:48 +02:00
Serhiy Storchaka
9c8dfcec64
[3.12] gh-107178: Add the C API tests for the Abstract Objects Layer (GH-107179) (#107728)
Cover all the Mapping Protocol, almost all the Sequence Protocol
(except PySequence_Fast) and a part of the Object Protocol.

Move existing tests to Lib/test/test_capi/test_abstract.py and
Modules/_testcapi/abstract.c.

Add also tests for PyDict C API..
(cherry picked from commit 16c9415fba)
2023-08-16 14:29:08 +02:00
Serhiy Storchaka
72534ca85c
[3.12] gh-107735: Add C API tests for PySys_GetObject() and PySys_SetObject() (GH-107736) (#107740)
[3.12] gh-107735: Add C API tests for PySys_GetObject() and PySys_SetObject() (GH-107736).
(cherry picked from commit bea5f93196)
2023-08-16 14:28:14 +02:00
Serhiy Storchaka
b5176a86bd
[3.12] gh-106844: Fix issues in _winapi.LCMapStringEx (GH-107832) (#107874)
* Strings with length from 2**31-1 to 2**32-2 always caused MemoryError,
   it doesn't matter how much memory is available.
* Strings with length exactly 2**32-1 caused OSError.
* Strings longer than 2**32-1 characters were truncated due to integer overflow bug.
* Strings containing the null character were truncated at the first null character.

Now strings longer than 2**31-1 characters caused OverflowError and the null character is allowed..
(cherry picked from commit 04cc01453d)
2023-08-16 12:10:42 +02:00
Serhiy Storchaka
bd2ef82a50
[3.12] gh-100061: Proper fix of the bug in the matching of possessive quantifiers (GH-102612) (#108003)
Restore the global Input Stream pointer after trying to match a sub-pattern.

.
(cherry picked from commit abd9cc52d9)

Co-authored-by: SKO <41810398+uyw4687@users.noreply.github.com>
2023-08-16 12:00:55 +02:00
Miss Islington (bot)
98dd9d9725
[3.12] gh-91054: make code watcher tests resilient to other watchers (GH-107821) (#107835)
gh-91054: make code watcher tests resilient to other watchers (GH-107821)
(cherry picked from commit 2ec16fed14)

Co-authored-by: Carl Meyer <carl@oddbird.net>
2023-08-11 16:13:14 +02:00
Miss Islington (bot)
93fcf75878
[3.12] gh-107077: Raise SSLCertVerificationError even if the error is set via SSL_ERROR_SYSCALL (GH-107586) (#107587)
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
Co-authored-by: T. Wouters <thomas@python.org>
2023-08-03 15:09:29 +01:00
Charlie Zhao
99518bbbf4
[3.12] gh-106263: Fix segfault in signaldict_repr in _decimal module (#… (#107491)
Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>

(cherry picked from commit 3979150a0d)
2023-07-31 14:34:16 +02:00