Skip to content

Improvements to test.support.interpreters.Interpreter #132775

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ericsnowcurrently opened this issue Apr 21, 2025 · 1 comment
Closed

Improvements to test.support.interpreters.Interpreter #132775

ericsnowcurrently opened this issue Apr 21, 2025 · 1 comment
Assignees
Labels
3.14 bugs and security fixes stdlib Python modules in the Lib dir topic-subinterpreters type-feature A feature request or enhancement

Comments

@ericsnowcurrently
Copy link
Member

ericsnowcurrently commented Apr 21, 2025

Interpreter.call() should be able to support arbitrary callables, full args, and return values.

Linked PRs

@ericsnowcurrently ericsnowcurrently added the type-bug An unexpected behavior, bug, or error label Apr 21, 2025
@ericsnowcurrently ericsnowcurrently self-assigned this Apr 21, 2025
@ericsnowcurrently ericsnowcurrently added stdlib Python modules in the Lib dir topic-subinterpreters 3.14 bugs and security fixes labels Apr 21, 2025
ericsnowcurrently added a commit that referenced this issue Apr 28, 2025
…h-132974)

This change consists of adding tests and moving code around, with some renaming thrown in.
ericsnowcurrently added a commit that referenced this issue Apr 28, 2025
…eUTF8() (gh-132979)

They are derived from the existing `PyModule_GetFilenameObject().

They are used by a later change related to pickle and handling __main__.
ericsnowcurrently added a commit that referenced this issue Apr 28, 2025
We replace it with _Py_GetMainModule(), and add _Py_CheckMainModule(), but both in the internal-only C-API.  We also add _PyImport_GetModulesRef(), which is the equivalent of _PyImport_GetModules(), but which increfs before the lock is released.

This is used by a later change related to pickle and handling __main__.
ericsnowcurrently added a commit that referenced this issue Apr 28, 2025
This is the base for several other XIData wrappers, like pickle and marshal. It is essentially a refactor of the existing bytes XIData code.
ericsnowcurrently added a commit that referenced this issue Apr 28, 2025
Note that the bulk of this change is tests.
ericsnowcurrently added a commit that referenced this issue Apr 29, 2025
The function indicates whether or not the function has a return statement.

This is used by a later change related treating some functions like scripts.
@markshannon
Copy link
Member

Could you elaborate what the "minor issues" are?
Either as a task list or sub issues?

It isn't clear to me why, for example, #132981 is needed, or if it is the right solution to whatever the problem is.

ericsnowcurrently added a commit that referenced this issue Apr 30, 2025
This helper is useful in a variety of ways, including in demonstrating how the different counts relate to one another.

It will be used in a later change to help identify if a function is "stateless", meaning it doesn't have any free vars or globals.

Note that a majority of this change is tests.
ericsnowcurrently added a commit that referenced this issue Apr 30, 2025
There's some extra complexity due to making sure we we get things right when handling functions and classes defined in the __main__ module.  This is also reflected in the tests, including the addition of extra functions in test.support.import_helper.
ericsnowcurrently added a commit to ericsnowcurrently/cpython that referenced this issue May 1, 2025
ericsnowcurrently added a commit that referenced this issue May 1, 2025
The change broke the s390 builds, so I'm reverting it while I investigate.

This reverts commit 94b4fcd.
ericsnowcurrently added a commit to ericsnowcurrently/cpython that referenced this issue May 1, 2025
ericsnowcurrently added a commit to ericsnowcurrently/cpython that referenced this issue May 23, 2025
ericsnowcurrently added a commit that referenced this issue May 23, 2025
This reverts commit 09e72cf, AKA gh-134511.

We are reverting due to refleaks on free-threaded builds.
ericsnowcurrently added a commit that referenced this issue May 23, 2025
…ta()" (gh-134600)

This reverts commit bbf8048, AKA gh-134515.

We are reverting due to refleaks on free-threaded builds.
lkollar pushed a commit to lkollar/cpython that referenced this issue May 26, 2025
…-133482)

It now supports a "full" fallback to _PyFunction_GetXIData() and then `_PyPickle_GetXIData()`.  There's also room for other fallback modes if that later makes sense.
lkollar pushed a commit to lkollar/cpython that referenced this issue May 26, 2025
lkollar pushed a commit to lkollar/cpython that referenced this issue May 26, 2025
…4440)

This change includes some semi-related refactoring of queues and channels.
lkollar pushed a commit to lkollar/cpython that referenced this issue May 26, 2025
lkollar pushed a commit to lkollar/cpython that referenced this issue May 26, 2025
This is mostly a refactor to clean things up a bit, most notably the "XI namespace" code.

Making the session opaque requires adding the following internal-only functions:

* _PyXI_NewSession()
* _PyXI_FreeSession()
* _PyXI_GetMainNamespace()
ericsnowcurrently added a commit to ericsnowcurrently/cpython that referenced this issue May 26, 2025
ericsnowcurrently added a commit that referenced this issue May 26, 2025
This reverts commit 8a793c4, AKA gh-134599.

This effectively re-applies commit 09e72cf (gh-134511)
ericsnowcurrently added a commit that referenced this issue May 26, 2025
This reverts commit 7476f90, AKA gh-134600.

This effectively unreverts commit bbf8048 (gh-134515).
ericsnowcurrently added a commit that referenced this issue May 27, 2025
…4758)

This is a small follow-up to gh-133481.  There's a corner case
in the behavior of PyImport_ImportModuleAttrString(), where
it expects __builtins__ to be set if __globals__ is set.
miss-islington pushed a commit to miss-islington/cpython that referenced this issue May 27, 2025
…ythongh-134758)

This is a small follow-up to pythongh-133481.  There's a corner case
in the behavior of PyImport_ImportModuleAttrString(), where
it expects __builtins__ to be set if __globals__ is set.
(cherry picked from commit 9b5e800)

Co-authored-by: Eric Snow <[email protected]>
ericsnowcurrently added a commit that referenced this issue May 27, 2025
…gh-134794)

This is a small follow-up to gh-133481.  There's a corner case
in the behavior of PyImport_ImportModuleAttrString(), where
it expects __builtins__ to be set if __globals__ is set.

(cherry picked from commit 9b5e800, AKA gh-134758)

Co-authored-by: Eric Snow <[email protected]>
ericsnowcurrently added a commit that referenced this issue May 29, 2025
The problem we're fixing here is that we were using PyDict_Size() on "defaults",
which it is actually a tuple.  We're also adding some explicit type checks.

This is a follow-up to gh-133221/gh-133528.
miss-islington pushed a commit to miss-islington/cpython that referenced this issue May 29, 2025
The problem we're fixing here is that we were using PyDict_Size() on "defaults",
which it is actually a tuple.  We're also adding some explicit type checks.

This is a follow-up to pythongh-133221/pythongh-133528.
(cherry picked from commit dafd141)

Co-authored-by: Eric Snow <[email protected]>
ericsnowcurrently added a commit that referenced this issue May 29, 2025
gh-132775: Fix _PyFunctIon_VerifyStateless() ()

The problem we're fixing here is that we were using PyDict_Size() on "defaults",
which it is actually a tuple.  We're also adding some explicit type checks.

This is a follow-up to gh-133221/gh-133528.

(cherry picked from commit dafd141, AKA gh-134900)

Co-authored-by: Eric Snow <[email protected]>
ericsnowcurrently added a commit that referenced this issue May 30, 2025
It now supports most callables, full args, and return values.
miss-islington pushed a commit to miss-islington/cpython that referenced this issue May 30, 2025
…h-133484)

It now supports most callables, full args, and return values.
(cherry picked from commit 52deabe)

Co-authored-by: Eric Snow <[email protected]>
ericsnowcurrently pushed a commit that referenced this issue May 30, 2025
)

It now supports most callables, full args, and return values.

(cherry picked from commit 52deabe, AKA gh-133484)

Co-authored-by: Eric Snow [email protected]
@github-project-automation github-project-automation bot moved this from Todo to Done in Subinterpreters May 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.14 bugs and security fixes stdlib Python modules in the Lib dir topic-subinterpreters type-feature A feature request or enhancement
Projects
Status: Done
Development

No branches or pull requests

2 participants