Commit graph

29 commits

Author SHA1 Message Date
sobolevn
06e347b846
gh-136285: Improve pickle protocol testing in test_interpreters (#136286)
Some checks are pending
Tests / Hypothesis tests on Ubuntu (push) Blocked by required conditions
Tests / Change detection (push) Waiting to run
Tests / Docs (push) Blocked by required conditions
Tests / Check if Autoconf files are up to date (push) Blocked by required conditions
Tests / Check if generated files are up to date (push) Blocked by required conditions
Tests / (push) Blocked by required conditions
Tests / Windows MSI (push) Blocked by required conditions
Tests / WASI (push) Blocked by required conditions
Tests / Ubuntu SSL tests with OpenSSL (push) Blocked by required conditions
Tests / Address sanitizer (push) Blocked by required conditions
Tests / Undefined behavior sanitizer (push) Blocked by required conditions
Tests / Cross build Linux (push) Blocked by required conditions
Tests / CIFuzz (push) Blocked by required conditions
Tests / All required checks pass (push) Blocked by required conditions
Lint / lint (push) Waiting to run
mypy / Run mypy on Lib/_pyrepl (push) Waiting to run
mypy / Run mypy on Lib/test/libregrtest (push) Waiting to run
mypy / Run mypy on Lib/tomllib (push) Waiting to run
mypy / Run mypy on Tools/build (push) Waiting to run
mypy / Run mypy on Tools/cases_generator (push) Waiting to run
mypy / Run mypy on Tools/clinic (push) Waiting to run
mypy / Run mypy on Tools/jit (push) Waiting to run
mypy / Run mypy on Tools/peg_generator (push) Waiting to run
2025-07-06 07:35:30 +00:00
Peter Bierma
15f2bac02c
gh-135450: Remove assertion in _PyCode_CheckNoExternalState (gh-135466)
The assertion reflected a misunderstanding of situations where "hidden" variables might exist,
namely generator expressions and comprehensions.
2025-06-18 17:31:23 -06:00
Eric Snow
269e19e0a7
gh-132775: Fix Interpreter.call() __main__ Visibility (gh-135595)
As noted in the new tests, there are a few situations we must carefully accommodate
for functions that get pickled during interp.call().  We do so by running the script
from the main interpreter's __main__ module in a hidden module in the other
interpreter.  That hidden module is used as the function __globals__.
2025-06-17 13:16:59 -06:00
Eric Snow
a450a0ddec
gh-135443: Sometimes Fall Back to __main__.__dict__ For Globals (gh-135491)
For several builtin functions, we now fall back to __main__.__dict__ for the globals
when there is no current frame and _PyInterpreterState_IsRunningMain() returns
true.  This allows those functions to be run with Interpreter.call().

The affected builtins:

* exec()
* eval()
* globals()
* locals()
* vars()
* dir()

We take a similar approach with "stateless" functions, which don't use any
global variables.
2025-06-16 17:34:19 -06:00
Eric Snow
62143736b6
gh-134939: Add the concurrent.interpreters Module (gh-133958)
PEP-734 has been accepted (for 3.14).

(FTR, I'm opposed to putting this under the concurrent package, but
doing so is the SC condition under which the module can land in 3.14.)
2025-06-11 17:35:48 -06:00
Eric Snow
52deabefd0
gh-132775: Expand the Capability of Interpreter.call() (gh-133484)
It now supports most callables, full args, and return values.
2025-05-30 09:15:00 -06:00
Eric Snow
56743afe87
gh-132775: Unrevert "Use _PyCode GetScriptXIData()" (gh-134735)
This reverts commit 8a793c4a36, AKA gh-134599.

This effectively re-applies commit 09e72cf (gh-134511)
2025-05-26 11:50:10 -06:00
Eric Snow
8a793c4a36
gh-134557: Revert "gh-132775: Use _PyCode GetScriptXIData()" (gh-134599)
This reverts commit 09e72cf091, AKA gh-134511.

We are reverting due to refleaks on free-threaded builds.
2025-05-23 20:04:20 +00:00
Eric Snow
09e72cf091
gh-132775: Use _PyCode GetScriptXIData() (gh-134511) 2025-05-22 08:40:33 -06:00
Peter Bierma
27bd08273c
Revert "gh-128639: Don't assume one thread in subinterpreter finalization (gh-128640)" (gh-134256)
This reverts commit 9859791f9e.

The original change broke the iOS and android buildbots, where the tests are run single-process.
2025-05-19 12:22:05 -06:00
Peter Bierma
9859791f9e
gh-128639: Don't assume one thread in subinterpreter finalization (gh-128640)
Incidentally, this also fixed the warning not showing up if a subinterpreter wasn't
cleaned up via _interpreters.destroy. I had to update some of the tests as a result.
2025-05-19 10:24:08 -06:00
b-pass
f2de1e6861
gh-134144: Fix use-after-free in zapthreads() (#134145) 2025-05-18 20:32:29 +05:30
Eric Snow
cd9536a087
gh-132781: Cleanup Code Related to NotShareableError (gh-132782)
The following are added to the internal C-API:

* _PyErr_FormatV()
* _PyErr_SetModuleNotFoundError()
* _PyXIData_GetNotShareableErrorType()
* _PyXIData_FormatNotShareableError()

We also drop _PyXIData_lookup_context_t and _PyXIData_GetLookupContext().
2025-04-25 14:43:38 -06:00
Peter Bierma
46bfd26fb2
gh-127165: Disallow embedded NULL characters in _interpreters (#127199) 2024-12-01 06:33:23 +00:00
Peter Bierma
01415213d7
gh-126223: Propagate unicode errors in _interpreters.create() (#126224)
Co-authored-by: sobolevn <mail@sobolevn.me>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2024-10-31 17:14:37 +03:00
Victor Stinner
f916b77fea
gh-120417: Remove unused imports in tests (part 3) (#120631) 2024-06-17 21:04:58 +02:00
Pablo Galindo Salgado
345e1e04ec
gh-112730: Make the test suite resilient to color-activation environment variables (#117672) 2024-04-24 21:25:22 +01:00
Eric Snow
03e3e31723
gh-76785: Rename _xxsubinterpreters to _interpreters (gh-117791)
See https://discuss.python.org/t/pep-734-multiple-interpreters-in-the-stdlib/41147/26.
2024-04-24 16:18:24 +00:00
Eric Snow
3831144f9c
gh-76785: Fix Windows Refleak in test_interpreters (gh-117913)
gh-117662 introduced some refleaks, or, rather, exposed some existing refleaks.  The leaks are coming when test.support.os_helper is imported in a "legacy" interpreter.  I've updated test.test_interpreters.utils to avoid importing os_helper, which fixes the leaks.  I'll address the root cause separately.
2024-04-15 20:16:37 -06:00
Eric Snow
fd259fdabe
gh-76785: Handle Legacy Interpreters Properly (gh-117490)
This is similar to the situation with threading._DummyThread.  The methods (incl. __del__()) of interpreters.Interpreter objects must be careful with interpreters not created by interpreters.create().  The simplest thing to start with is to disable any method that modifies or runs in the interpreter.  As part of this, the runtime keeps track of where an interpreter was created.  We also handle interpreter "refcounts" properly.
2024-04-11 23:23:25 +00:00
Sam Gross
25f6ff5d3e
gh-117649: Raise ImportError for unsupported modules in free-threaded build (#117651)
The free-threaded build does not currently support the combination of
single-phase init modules and non-isolated subinterpreters. Ensure that
`check_multi_interp_extensions` is always `True` for subinterpreters in
the free-threaded build so that importing these modules raises an
`ImportError`.
2024-04-11 15:00:54 -04:00
Eric Snow
993c3cca16
gh-76785: Add More Tests to test_interpreters.test_api (gh-117662)
In addition to the increase test coverage, this is a precursor to sorting out how we handle interpreters created directly via the C-API.
2024-04-10 18:37:01 -06:00
Eric Snow
976bcb2379
gh-76785: Raise InterpreterError, Not RuntimeError (gh-117489)
I had meant to switch everything to InterpreterError when I added it a while back.  At the time I missed a few key spots.

As part of this, I've added print-the-exception to _PyXI_InitTypes() and fixed an error case in `_PyStaticType_InitBuiltin().
2024-04-03 10:58:39 -06:00
Eric Snow
857d3151c9
gh-76785: Consolidate Some Interpreter-related Testing Helpers (gh-117485)
This eliminates the duplication of functionally identical helpers in the _testinternalcapi and _xxsubinterpreters modules.
2024-04-02 23:16:50 +00:00
Eric Snow
4402b3cbcf
gh-76785: Minor Improvements to "interpreters" Module (gh-116328)
This includes adding pickle support to various classes, and small changes to improve the maintainability of the low-level _xxinterpqueues module.
2024-03-05 08:54:46 -07:00
Eric Snow
e80abd57a8
gh-76785: Update test.support.interpreters to Align With PEP 734 (gh-115566)
This brings the code under test.support.interpreters, and the corresponding extension modules, in line with recent updates to PEP 734.

(Note: PEP 734 has not been accepted at this time.  However, we are using an internal copy of the implementation in the test suite to exercise the existing subinterpreters feature.)
2024-02-28 16:08:08 -07:00
Eric Snow
8a4c1f3ff1
gh-76785: Show the Traceback for Uncaught Subinterpreter Exceptions (gh-113034)
When an exception is uncaught in Interpreter.exec_sync(), it helps to show that exception's error display if uncaught in the calling interpreter.  We do so here by generating a TracebackException in the subinterpreter and passing it between interpreters using pickle.
2023-12-13 00:00:54 +00:00
Eric Snow
9898e61041
gh-76785: Add Interpreter.prepare_main() (gh-113021)
This is one of the last pieces to get test.support.interpreters in sync with PEP 734.
2023-12-12 18:06:06 +00:00
Eric Snow
86a77f4e1a
gh-76785: Fixes for test.support.interpreters (gh-112982)
This involves a number of changes for PEP 734.
2023-12-12 08:24:31 -07:00