Commit graph

13675 commits

Author SHA1 Message Date
Eric Snow 757cc35b6b
gh-84570: Implement Waiting in SendChannel.send() (gh-110565)
We had been faking it (poorly).

We will add timeouts separately.
2023-10-10 09:35:14 +00:00
Donghee Na 67e8d416cc
gh-109693: Use pyatomic.h for signal module (gh-110480) 2023-10-10 08:26:29 +09:00
Jakub Kulík 3b1580af07
gh-78469: Declare missing sethostname for Solaris 10 (#109447)
Add OS version specific macro for Solaris: Py_SUNOS_VERSION.
2023-10-09 21:18:05 +00:00
Illia Volochii ea7b53ff67
gh-107652: Set up CIFuzz to run fuzz targets continuously (#107653)
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2023-10-09 09:30:10 -06:00
Eric Snow 7bd560ce8d
gh-76785: Add SendChannel.send_buffer() (#110246)
(This is still a test module.)
2023-10-09 07:39:51 -06:00
Bo Anderson f4cb0d27cc
gh-109191: Fix build with newer editline (gh-110239) 2023-10-09 13:21:20 +00:00
Nikita Sobolev ea39c877c0
gh-110525: Cover PySet_Add corner case with frozenset objects (GH-110544) 2023-10-09 14:04:49 +03:00
Nikita Sobolev 89df5b73d0
gh-110549: Remove unused includes of <stddef.h> in _testcapi (GH-110552) 2023-10-09 10:37:57 +00:00
Nikita Sobolev c49edd7d9c
gh-110525: Add CAPI tests for set and frozenset objects (GH-110526) 2023-10-09 11:57:48 +03:00
Serhiy Storchaka d96a8cdfe2
gh-89902: Deprecate non-standard format specifier "N" for Decimal (GH-110508)
It was not documented and only supported in the C implementation.
2023-10-08 10:01:39 +03:00
Masaru Tsuchiyama de2a4036cb
gh-108277: Add os.timerfd_create() function (#108382)
Add wrapper for timerfd_create, timerfd_settime, and timerfd_gettime to os module.

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2023-10-07 19:33:22 +02:00
Eric Snow 92ca90b762
gh-76785: Support Running Some Functions in Subinterpreters (gh-110251)
This specifically refers to `test.support.interpreters.Interpreter.run()`.
2023-10-06 17:52:22 -06:00
Charlie Zhao de1052245f
gh-106078: Suppress the warning caused by multi-phase initialization of decimal (#107524) 2023-10-07 00:15:19 +01:00
Shantanu f013b47504
gh-110489: Optimise math.ceil for known exact float (#108801)
This matches a similar optimisation done for math.floor in
https://github.com/python/cpython/pull/21072
2023-10-06 22:57:18 +00:00
박문식 d33aa18f15
gh-82367: Use FindFirstFile Win32 API in ntpath.realpath() (GH-110298)
* Use `FindFirstFile` Win32 API to fix a bug where `ntpath.realpath()`
breaks out of traversing a series of paths where a (handled)
`ERROR_ACCESS_DENIED` or `ERROR_SHARING_VIOLATION` occurs.
* Update docs to reflect that `ntpath.realpath()` eliminates MS-DOS
style names.
2023-10-05 09:49:07 -05:00
Nikita Sobolev 2bbbab212f
gh-110365: Fix error overwrite in termios.tcsetattr (#110366)
Co-authored-by: Erlend E. Aasland <erlend@python.org>
2023-10-05 11:02:52 +00:00
Sam Gross cf6f23b0e3
gh-88402: Add new sysconfig variables on Windows (GH-110049)
Co-authored-by: Filipe Laíns <filipe.lains@gmail.com>
2023-10-04 22:50:29 +00:00
Eric Snow ee317f7ddd
gh-76785: Print the Traceback from Interpreter.run() (gh-110322)
This is a temporary solution.  The full fix may involve serializing the traceback in some form.

(FYI, I merged this yesterday and the reverted it due to buildbot failures.  See gh-110248.)
2023-10-04 11:57:03 -06:00
Mark Shannon bf4bc36069
GH-109369: Merge all eval-breaker flags and monitoring version into one word. (GH-109846) 2023-10-04 16:09:48 +01:00
Nikita Sobolev 43baddc2b9
gh-110260: Check for PyList_SetItem() errors in termios module (GH-110261) 2023-10-04 15:42:17 +03:00
Eric Snow 269005e784
gh-110300: Fix Refleaks in test_interpreters and test__xxinterpchannels (gh-110318) 2023-10-04 00:36:50 +00:00
Eric Snow 4467d2c3ac
Revert "gh-76785: Print the Traceback from Interpreter.run() (gh-110248)" (gh-110314)
This reverts commit 6bc889aedc.

That commit is causing some buildbot failures.
2023-10-03 21:18:25 +00:00
Eric Snow 6bc889aedc
gh-76785: Print the Traceback from Interpreter.run() (gh-110248)
This is a temporary fix. The full fix may involve serializing the traceback in some form.
2023-10-03 14:41:02 -06:00
Victor Stinner d73501602f
gh-108867: Add PyThreadState_GetUnchecked() function (#108870)
Add PyThreadState_GetUnchecked() function: similar to
PyThreadState_Get(), but don't issue a fatal error if it is NULL. The
caller is responsible to check if the result is NULL. Previously,
this function was private and known as _PyThreadState_UncheckedGet().
2023-10-03 16:53:51 +00:00
Eric Snow f5198b09e1
gh-109860: Use a New Thread State When Switching Interpreters, When Necessary (gh-110245)
In a few places we switch to another interpreter without knowing if it has a thread state associated with the current thread.  For the main interpreter there wasn't much of a problem, but for subinterpreters we were *mostly* okay re-using the tstate created with the interpreter (located via PyInterpreterState_ThreadHead()).  There was a good chance that tstate wasn't actually in use by another thread.

However, there are no guarantees of that.  Furthermore, re-using an already used tstate is currently fragile.  To address this, now we create a new thread state in each of those places and use it.

One consequence of this change is that PyInterpreterState_ThreadHead() may not return NULL (though that won't happen for the main interpreter).
2023-10-03 09:20:48 -06:00
Nikita Sobolev 4596c76d1a
gh-110241: Add missing error check to record_eval in _testinternalcapi (#110242) 2023-10-02 21:19:32 +00:00
Eric Snow a8f5dab58d
gh-76785: Module-level Fixes for test.support.interpreters (gh-110236)
* add RecvChannel.close() and SendChannel.close()
* make RecvChannel and SendChannel shareable
* expose ChannelEmptyError and ChannelNotEmptyError
2023-10-02 20:47:41 +00:00
Eric Snow 1dd9dee45d
gh-105716: Support Background Threads in Subinterpreters Consistently (gh-109921)
The existence of background threads running on a subinterpreter was preventing interpreters from getting properly destroyed, as well as impacting the ability to run the interpreter again. It also affected how we wait for non-daemon threads to finish.

We add PyInterpreterState.threads.main, with some internal C-API functions.
2023-10-02 20:12:12 +00:00
Eric Snow a040a32ea2
gh-109853: Fix sys.path[0] For Subinterpreters (gh-109994)
This change makes sure sys.path[0] is set properly for subinterpreters. Before, it wasn't getting set at all. This PR does not address the broader concerns from gh-109853.
2023-10-02 19:59:05 +00:00
Victor Stinner fc2cb86d21
gh-107073: Make PyObject_VisitManagedDict() public (#108763)
Make PyObject_VisitManagedDict() and PyObject_ClearManagedDict()
functions public in Python 3.13 C API.

* Rename _PyObject_VisitManagedDict() to PyObject_VisitManagedDict().
* Rename _PyObject_ClearManagedDict() to PyObject_ClearManagedDict().
* Document these functions.
2023-10-02 19:24:08 +02:00
Victor Stinner a46e960768
gh-109649: Use os.process_cpu_count() (#110165)
Replace os.cpu_count() with os.process_cpu_count() in modules:

* compileall
* concurrent.futures
* multiprocessing

Replace os.cpu_count() with os.process_cpu_count() in programs:

* _decimal deccheck.py test
* freeze.py
* multissltests.py
* python -m test (regrtest)
* wasm_build.py

Other changes:

* test.pythoninfo logs os.process_cpu_count().
* regrtest gets os.process_cpu_count() / os.cpu_count() in headers.
2023-10-01 03:14:57 +02:00
Victor Stinner c81521020d
gh-109649: Add os.process_cpu_count() function (#109907)
* Refactor os_sched_getaffinity_impl(): move variable definitions to
  their first assignment.
* Fix test_posix.test_sched_getaffinity(): restore the old CPU mask
  when the test completes!
* Doc: Specify that os.cpu_count() counts *logicial* CPUs.
* Doc: Specify that os.sched_getaffinity(0) is related to the calling
  thread.
2023-10-01 00:12:51 +02:00
Victor Stinner 7513994c92
gh-110014: Include explicitly <unistd.h> header (#110155)
* Remove unused <locale.h> includes.
* Remove unused <fcntl.h> include in traceback.h.
* Remove redundant <assert.h> and <stddef.h> includes. They  are already
  included by "Python.h".
* Remove <object.h> include in faulthandler.c. Python.h already includes it.
* Add missing <stdbool.h> in pycore_pythread.h if HAVE_PTHREAD_STUBS
  is defined.
* Fix also warnings in pthread_stubs.h: don't redefine macros if they
  are already defined, like the __NEED_pthread_t macro.
2023-09-30 20:06:45 +00:00
Donghee Na 501939c9c1
gh-105323: Update readline module to detect apple editline variant (gh-108665) 2023-09-29 21:18:18 +09:00
Victor Stinner 8b626a47ba
gh-110079: Remove extern "C" { ...} in C code (#110080) 2023-09-29 10:56:49 +02:00
Jelle Zijlstra 7dc2c5093e
gh-110045: Update symtable module for PEP 695 (#110066) 2023-09-29 02:08:04 +00:00
Victor Stinner 2e37a38bcb
gh-110052: Fix faulthandler for freed tstate (#110069)
faulthandler now detected freed interp and freed tstate, and no
longer dereference them.
2023-09-29 02:04:06 +00:00
Amin Alaee 7df8b16d28
gh-109782: Ensure os.path.isdir has the same signature on all platforms (GH-109790) 2023-09-28 16:17:30 +01:00
Ammar Askar a829356f86
gh-109098: Fuzz re module instead of internal sre (#109911)
* gh-109098: Fuzz re module instead of internal sre
* Fix c-analyzer globals test failure
* Put globals exception in ignored.tsv
2023-09-26 15:35:49 -07:00
Antoine Pitrou 0eb98837b6
gh-109593: Fix reentrancy issue in multiprocessing resource_tracker (#109629)
---------

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2023-09-26 13:57:25 +02:00
Serhiy Storchaka 8ac2085b80
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.
2023-09-26 10:56:33 +03:00
Radislav Chugunov 1b8f2366b3
gh-109795: _thread.start_new_thread: allocate thread bootstate using raw memory allocator (#109808) 2023-09-25 17:38:06 +02:00
Victor Stinner eeb9070437
gh-109723: Fix build of _testclinic_limited on WASM (#109842)
Make sure that the Py_BUILD_CORE macro is not defined.
2023-09-25 14:43:54 +00:00
Victor Stinner 8c521f090e
gh-104469: Convert _testcapi/vectorcall_limited.c to use AC (#109691)
Co-authored-by: nahyeon <55136494+nahyeon-an@users.noreply.github.com>
2023-09-25 13:24:19 +02:00
Serhiy Storchaka b8d1744e7b
gh-109611: Add convenient C API function _PyFile_Flush() (GH-109612) 2023-09-23 09:35:30 +03:00
Victor Stinner 09a25616a9
gh-109723: Disable Py_BUILD_CORE in _testcapi (#109727)
Make sure that the internal C API is not tested by mistake by
_testcapi.

Undefine Py_BUILD_CORE_BUILTIN and Py_BUILD_CORE_MODULE macros in
Modules/_testcapi/parts.h: move code from _testcapimodule.c.

heaptype_relative.c and vectorcall_limited.c are using the limited C
API which is incompatible with the internal C API.

Move test_long_numbits() from _testcapi to _testinternalcapi since it
uses the internal C API "pycore_long.h".

Fix Modules/_testcapi/pyatomic.c: don't include Python.h directly,
just include _testcapi/parts.h.

Ajust "make check-c-globals" for these changes.
2023-09-22 14:54:37 +00:00
Sam Gross 2aceb21ae6
gh-109693: Remove pycore_atomic_funcs.h (#109694)
_PyUnicode_FromId() now uses pyatomic.h functions instead.
2023-09-21 22:57:20 +02:00
Victor Stinner d4cea794a7
gh-109613: _pystat_fromstructstat() checks for exceptions (#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
2023-09-21 09:55:06 +02:00
James Gerity def828995a
fixes gh-109559: Update unicodedata for Unicode 15.1.0 (GH-109560)
---------

Co-authored-by: Benjamin Peterson <benjamin@python.org>
2023-09-19 22:07:47 -07:00
Ronan Pigott ddf2e953c2
gh-109033: Return filename with os.utime errors (#109034)
The filename was previously intentionally omitted from exception because
"it might confuse the user". Uncaught exceptions are not generally a
replacement for user-facing error messages, so obscuring this
information only has the effect of making the programmer's life more
difficult.
2023-09-20 01:18:23 +02:00