Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
5997f18
Convert _interpreters.create()
AA-Turner Aug 11, 2025
4b159b3
Convert _interpreters.destroy()
AA-Turner Aug 11, 2025
eda5fa0
Convert _interpreters.list_all()
AA-Turner Aug 11, 2025
699dc6d
Convert _interpreters.get_current()
AA-Turner Aug 11, 2025
c313b80
Convert _interpreters.get_main()
AA-Turner Aug 11, 2025
abe7aaa
Convert _interpreters.set___main___attrs()
AA-Turner Aug 11, 2025
6903b3f
Convert _interpreters.exec()
AA-Turner Aug 11, 2025
d0b2e8d
Convert _interpreters.run_string()
AA-Turner Aug 11, 2025
91d15b5
Convert _interpreters.run_func()
AA-Turner Aug 11, 2025
98a75b2
Convert _interpreters.call()
AA-Turner Aug 11, 2025
6d863cb
Convert _interpreters.is_shareable()
AA-Turner Aug 11, 2025
84217c8
Convert _interpreters.is_running()
AA-Turner Aug 11, 2025
bfed2bf
Convert _interpreters.get_config()
AA-Turner Aug 11, 2025
599bde4
Convert _interpreters.whence()
AA-Turner Aug 11, 2025
20c67ee
Convert _interpreters.incref()
AA-Turner Aug 11, 2025
b7a49d3
Convert _interpreters.decref()
AA-Turner Aug 11, 2025
d07daae
Convert _interpreters.capture_exception()
AA-Turner Aug 11, 2025
9e5577e
Add note on new_config()
AA-Turner Aug 11, 2025
eb21bb1
Indicate positional-only parameters
AA-Turner Aug 11, 2025
6e26591
Update docstrings
AA-Turner Aug 11, 2025
08dce29
Update tests
AA-Turner Aug 11, 2025
af65824
Blurb
AA-Turner Aug 11, 2025
435389f
make regen-all
AA-Turner Aug 11, 2025
be2fe07
Fix new_config_doc
AA-Turner Aug 11, 2025
073e2ff
Undo docstring changes
AA-Turner Aug 11, 2025
1cdf313
Revert "Indicate positional-only parameters"
AA-Turner Aug 11, 2025
e8f0b6c
Serhiy's review
AA-Turner Aug 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Indicate positional-only parameters
  • Loading branch information
AA-Turner committed Aug 11, 2025
commit eb21bb11264b82709b31ffffdc1800105c92a539
46 changes: 30 additions & 16 deletions Modules/_interpretersmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,7 @@ overriding the initial values.");
/*[clinic input]
_interpreters.create
config as configobj: object(py_default="'isolated'") = NULL
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the default value None?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per the docstring, "The default is 'isolated'.". I think showing this is more helpful than None, what do you think?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the code the default is equivalent to None. I did not look deeper. @ericsnowcurrently?

/
*
reqrefs: bool = False

Expand All @@ -868,7 +869,7 @@ is "isolated".

static PyObject *
_interpreters_create_impl(PyObject *module, PyObject *configobj, int reqrefs)
/*[clinic end generated code: output=c1cc6835b1277c16 input=c6d69e3ff2315a65]*/
/*[clinic end generated code: output=c1cc6835b1277c16 input=9b240f749f0f0972]*/
{
PyInterpreterConfig config;
if (config_from_object(configobj, &config) < 0) {
Expand Down Expand Up @@ -906,6 +907,7 @@ _interpreters_create_impl(PyObject *module, PyObject *configobj, int reqrefs)
/*[clinic input]
_interpreters.destroy
id: object
/
Comment thread
AA-Turner marked this conversation as resolved.
Outdated
*
restrict as restricted: bool = False

Expand All @@ -917,7 +919,7 @@ So does an unrecognized ID.

static PyObject *
_interpreters_destroy_impl(PyObject *module, PyObject *id, int restricted)
/*[clinic end generated code: output=0bc20da8700ab4dd input=561bdd6537639d40]*/
/*[clinic end generated code: output=0bc20da8700ab4dd input=d2cfa1ef3b4a4ea5]*/
{
// Look up the interpreter.
int reqready = 0;
Expand Down Expand Up @@ -1032,7 +1034,8 @@ _interpreters_get_main_impl(PyObject *module)
/*[clinic input]
_interpreters.set___main___attrs
id: object
updates: object(subclass_of='&PyDict_Type')
ns as updates: object(subclass_of='&PyDict_Type')
Comment thread
AA-Turner marked this conversation as resolved.
Outdated
/
Comment thread
AA-Turner marked this conversation as resolved.
Outdated
*
restrict as restricted: bool = False

Expand All @@ -1042,7 +1045,7 @@ Bind the given attributes in the interpreter's __main__ module.
static PyObject *
_interpreters_set___main___attrs_impl(PyObject *module, PyObject *id,
PyObject *updates, int restricted)
/*[clinic end generated code: output=f3803010cb452bf0 input=d16ab8d81371f86a]*/
/*[clinic end generated code: output=f3803010cb452bf0 input=69d409c4dd04dab9]*/
{
// Look up the interpreter.
int reqready = 1;
Expand Down Expand Up @@ -1106,6 +1109,7 @@ _handle_script_error(struct run_result *runres)
/*[clinic input]
_interpreters.exec
id: object
/
Comment thread
AA-Turner marked this conversation as resolved.
Outdated
code: object
shared: object(subclass_of='&PyDict_Type', c_default='NULL') = {}
*
Expand All @@ -1130,7 +1134,7 @@ is ignored, including its __globals__ dict.
static PyObject *
_interpreters_exec_impl(PyObject *module, PyObject *id, PyObject *code,
PyObject *shared, int restricted)
/*[clinic end generated code: output=492057c4f10dc304 input=5a22c1ed0c5dbcf3]*/
/*[clinic end generated code: output=492057c4f10dc304 input=687f3f6ac5294593]*/
{
PyThreadState *tstate = _PyThreadState_GET();
int reqready = 1;
Expand Down Expand Up @@ -1162,6 +1166,7 @@ _interpreters_exec_impl(PyObject *module, PyObject *id, PyObject *code,
/*[clinic input]
_interpreters.run_string
id: object
/
Comment thread
AA-Turner marked this conversation as resolved.
Outdated
script: unicode
shared: object(subclass_of='&PyDict_Type', c_default='NULL') = {}
*
Expand Down Expand Up @@ -1213,6 +1218,7 @@ _interpreters_run_string_impl(PyObject *module, PyObject *id,
/*[clinic input]
_interpreters.run_func
id: object
/
Comment thread
AA-Turner marked this conversation as resolved.
Outdated
func: object
shared: object(subclass_of='&PyDict_Type', c_default='NULL') = {}
*
Expand All @@ -1229,7 +1235,7 @@ are not supported. Methods and other callables are not supported either.
static PyObject *
_interpreters_run_func_impl(PyObject *module, PyObject *id, PyObject *func,
PyObject *shared, int restricted)
/*[clinic end generated code: output=131f7202ca4a0c5e input=2d62bb9b9eaf4948]*/
/*[clinic end generated code: output=131f7202ca4a0c5e input=aa2dbab6f7354cd6]*/
{
#define FUNCNAME MODULE_NAME_STR ".run_func"
PyThreadState *tstate = _PyThreadState_GET();
Expand Down Expand Up @@ -1275,6 +1281,7 @@ _interpreters_run_func_impl(PyObject *module, PyObject *id, PyObject *func,
/*[clinic input]
_interpreters.call
id: object
/
Comment thread
AA-Turner marked this conversation as resolved.
Outdated
callable: object
args as args_obj: object(subclass_of='&PyTuple_Type', c_default='NULL') = ()
kwargs as kwargs_obj: object(subclass_of='&PyDict_Type', c_default='NULL') = {}
Expand All @@ -1291,7 +1298,7 @@ static PyObject *
_interpreters_call_impl(PyObject *module, PyObject *id, PyObject *callable,
PyObject *args_obj, PyObject *kwargs_obj,
int preserve_exc, int restricted)
/*[clinic end generated code: output=983ee27b3c43f6ef input=77590fdb3f519d65]*/
/*[clinic end generated code: output=983ee27b3c43f6ef input=826c8dab4b1059b4]*/
{
PyThreadState *tstate = _PyThreadState_GET();
int reqready = 1;
Expand Down Expand Up @@ -1330,13 +1337,14 @@ _interpreters_call_impl(PyObject *module, PyObject *id, PyObject *callable,
/*[clinic input]
_interpreters.is_shareable
obj: object
/
Comment thread
AA-Turner marked this conversation as resolved.
Outdated

Return True if the object's data may be shared between interpreters and False otherwise.
[clinic start generated code]*/

static PyObject *
_interpreters_is_shareable_impl(PyObject *module, PyObject *obj)
/*[clinic end generated code: output=227856926a22940b input=72b9a36bdf1d2a53]*/
_interpreters_is_shareable(PyObject *module, PyObject *obj)
/*[clinic end generated code: output=f2169d4c1f5d7bca input=4239989a8634b292]*/
{
PyThreadState *tstate = _PyThreadState_GET();
if (_PyObject_CheckXIData(tstate, obj) == 0) {
Expand All @@ -1350,6 +1358,7 @@ _interpreters_is_shareable_impl(PyObject *module, PyObject *obj)
/*[clinic input]
_interpreters.is_running
id: object
/
Comment thread
AA-Turner marked this conversation as resolved.
Outdated
*
restrict as restricted: bool = False

Expand All @@ -1358,7 +1367,7 @@ Return whether or not the identified interpreter is running.

static PyObject *
_interpreters_is_running_impl(PyObject *module, PyObject *id, int restricted)
/*[clinic end generated code: output=32a6225d5ded9bdb input=3291578d04231125]*/
/*[clinic end generated code: output=32a6225d5ded9bdb input=a4d98a82fcb4bf6e]*/
{
int reqready = 1;
PyInterpreterState *interp = \
Expand All @@ -1377,6 +1386,7 @@ _interpreters_is_running_impl(PyObject *module, PyObject *id, int restricted)
/*[clinic input]
_interpreters.get_config
id as idobj: object
/
Comment thread
AA-Turner marked this conversation as resolved.
Outdated
*
restrict as restricted: bool = False

Expand All @@ -1386,7 +1396,7 @@ Return a representation of the config used to initialize the interpreter.
static PyObject *
_interpreters_get_config_impl(PyObject *module, PyObject *idobj,
int restricted)
/*[clinic end generated code: output=63f81d35c2fe1387 input=aa38d50f534eb3c5]*/
/*[clinic end generated code: output=63f81d35c2fe1387 input=79d88cf77a8ba034]*/
{
if (idobj == Py_None) {
idobj = NULL;
Expand Down Expand Up @@ -1417,13 +1427,14 @@ _interpreters_get_config_impl(PyObject *module, PyObject *idobj,
/*[clinic input]
_interpreters.whence
id: object
/
Comment thread
AA-Turner marked this conversation as resolved.
Outdated

Return an identifier for where the interpreter was created.
[clinic start generated code]*/

static PyObject *
_interpreters_whence_impl(PyObject *module, PyObject *id)
/*[clinic end generated code: output=ef2c21ab106c2c20 input=eeede0a2fbfa2968]*/
_interpreters_whence(PyObject *module, PyObject *id)
/*[clinic end generated code: output=e558d207672470cf input=6148f02c882e39f6]*/
{
PyInterpreterState *interp = look_up_interp(id);
if (interp == NULL) {
Expand All @@ -1438,6 +1449,7 @@ _interpreters_whence_impl(PyObject *module, PyObject *id)
/*[clinic input]
_interpreters.incref
id: object
/
Comment thread
AA-Turner marked this conversation as resolved.
Outdated
*
implieslink: bool = False
restrict as restricted: bool = False
Expand All @@ -1447,7 +1459,7 @@ _interpreters.incref
static PyObject *
_interpreters_incref_impl(PyObject *module, PyObject *id, int implieslink,
int restricted)
/*[clinic end generated code: output=eccaa4e03fbe8ee2 input=a0a614748f2e348c]*/
/*[clinic end generated code: output=eccaa4e03fbe8ee2 input=a49374f447dead6f]*/
{
int reqready = 1;
PyInterpreterState *interp = \
Expand All @@ -1469,14 +1481,15 @@ _interpreters_incref_impl(PyObject *module, PyObject *id, int implieslink,
/*[clinic input]
_interpreters.decref
id: object
/
Comment thread
AA-Turner marked this conversation as resolved.
Outdated
*
restrict as restricted: bool = False

[clinic start generated code]*/

static PyObject *
_interpreters_decref_impl(PyObject *module, PyObject *id, int restricted)
/*[clinic end generated code: output=5c54db4b22086171 input=c4aa34f09c44e62a]*/
/*[clinic end generated code: output=5c54db4b22086171 input=6f82beeae0b1c2b1]*/
{
int reqready = 1;
PyInterpreterState *interp = \
Expand All @@ -1494,6 +1507,7 @@ _interpreters_decref_impl(PyObject *module, PyObject *id, int restricted)
/*[clinic input]
_interpreters.capture_exception
exc_arg: object(c_default='NULL') = None
/

Return a snapshot of an exception.

Expand All @@ -1503,7 +1517,7 @@ The returned snapshot is the same as what _interpreters.exec() returns.

static PyObject *
_interpreters_capture_exception_impl(PyObject *module, PyObject *exc_arg)
/*[clinic end generated code: output=ef3f5393ef9c88a6 input=e607efac7eb95fba]*/
/*[clinic end generated code: output=ef3f5393ef9c88a6 input=e67d59d7fbb6d58c]*/
{
PyObject *exc = exc_arg;
if (exc == NULL || exc == Py_None) {
Expand Down
Loading