Skip to content

GH-137630: Convert _interpreters to use Argument Clinic #137631

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

Open
wants to merge 27 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
11 changes: 11 additions & 0 deletions Include/internal/pycore_global_objects_fini_generated.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions Include/internal/pycore_global_strings.h
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ struct _Py_global_strings {
STRUCT_FOR_ID(call)
STRUCT_FOR_ID(call_exception_handler)
STRUCT_FOR_ID(call_soon)
STRUCT_FOR_ID(callable)
STRUCT_FOR_ID(callback)
STRUCT_FOR_ID(cancel)
STRUCT_FOR_ID(capath)
Expand Down Expand Up @@ -368,6 +369,7 @@ struct _Py_global_strings {
STRUCT_FOR_ID(command)
STRUCT_FOR_ID(comment_factory)
STRUCT_FOR_ID(compile_mode)
STRUCT_FOR_ID(config)
STRUCT_FOR_ID(consts)
STRUCT_FOR_ID(context)
STRUCT_FOR_ID(contravariant)
Expand Down Expand Up @@ -426,6 +428,7 @@ struct _Py_global_strings {
STRUCT_FOR_ID(errors)
STRUCT_FOR_ID(event)
STRUCT_FOR_ID(eventmask)
STRUCT_FOR_ID(exc)
STRUCT_FOR_ID(exc_type)
STRUCT_FOR_ID(exc_value)
STRUCT_FOR_ID(excepthook)
Expand Down Expand Up @@ -497,6 +500,7 @@ struct _Py_global_strings {
STRUCT_FOR_ID(identity_hint)
STRUCT_FOR_ID(ignore)
STRUCT_FOR_ID(imag)
STRUCT_FOR_ID(implieslink)
STRUCT_FOR_ID(importlib)
STRUCT_FOR_ID(in_fd)
STRUCT_FOR_ID(include_aliases)
Expand Down Expand Up @@ -546,6 +550,7 @@ struct _Py_global_strings {
STRUCT_FOR_ID(kw)
STRUCT_FOR_ID(kw1)
STRUCT_FOR_ID(kw2)
STRUCT_FOR_ID(kwargs)
STRUCT_FOR_ID(kwdefaults)
STRUCT_FOR_ID(label)
STRUCT_FOR_ID(last)
Expand Down Expand Up @@ -662,6 +667,7 @@ struct _Py_global_strings {
STRUCT_FOR_ID(pos1)
STRUCT_FOR_ID(pos2)
STRUCT_FOR_ID(posix)
STRUCT_FOR_ID(preserve_exc)
STRUCT_FOR_ID(print_file_and_line)
STRUCT_FOR_ID(priority)
STRUCT_FOR_ID(progress)
Expand Down Expand Up @@ -689,9 +695,12 @@ struct _Py_global_strings {
STRUCT_FOR_ID(reload)
STRUCT_FOR_ID(repl)
STRUCT_FOR_ID(replace)
STRUCT_FOR_ID(reqrefs)
STRUCT_FOR_ID(require_ready)
STRUCT_FOR_ID(reserved)
STRUCT_FOR_ID(reset)
STRUCT_FOR_ID(resetids)
STRUCT_FOR_ID(restrict)
STRUCT_FOR_ID(return)
STRUCT_FOR_ID(reverse)
STRUCT_FOR_ID(reversed)
Expand All @@ -718,6 +727,7 @@ struct _Py_global_strings {
STRUCT_FOR_ID(setsigmask)
STRUCT_FOR_ID(setstate)
STRUCT_FOR_ID(shape)
STRUCT_FOR_ID(shared)
STRUCT_FOR_ID(show_cmd)
STRUCT_FOR_ID(signed)
STRUCT_FOR_ID(size)
Expand Down Expand Up @@ -788,6 +798,7 @@ struct _Py_global_strings {
STRUCT_FOR_ID(uid)
STRUCT_FOR_ID(unlink)
STRUCT_FOR_ID(unraisablehook)
STRUCT_FOR_ID(updates)
STRUCT_FOR_ID(uri)
STRUCT_FOR_ID(usedforsecurity)
STRUCT_FOR_ID(value)
Expand Down
11 changes: 11 additions & 0 deletions Include/internal/pycore_runtime_init_generated.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions Include/internal/pycore_unicodeobject_generated.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Lib/test/test__interpreters.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,19 +474,19 @@ def setUp(self):

def test_signatures(self):
# See https://github.com/python/cpython/issues/126654
msg = r'_interpreters.exec\(\) argument 3 must be dict, not int'
msg = r"exec\(\) argument 'shared' must be dict, not int"
with self.assertRaisesRegex(TypeError, msg):
_interpreters.exec(self.id, 'a', 1)
with self.assertRaisesRegex(TypeError, msg):
_interpreters.exec(self.id, 'a', shared=1)
msg = r'_interpreters.run_string\(\) argument 3 must be dict, not int'
msg = r"run_string\(\) argument 'shared' must be dict, not int"
with self.assertRaisesRegex(TypeError, msg):
_interpreters.run_string(self.id, 'a', shared=1)
msg = r'_interpreters.run_func\(\) argument 3 must be dict, not int'
msg = r"run_func\(\) argument 'shared' must be dict, not int"
with self.assertRaisesRegex(TypeError, msg):
_interpreters.run_func(self.id, lambda: None, shared=1)
# See https://github.com/python/cpython/issues/135855
msg = r'_interpreters.set___main___attrs\(\) argument 2 must be dict, not int'
msg = r"set___main___attrs\(\) argument 'updates' must be dict, not int"
with self.assertRaisesRegex(TypeError, msg):
_interpreters.set___main___attrs(self.id, 1)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
The :mod:`!_interpreters` module now uses Argument Clinic to parse arguments.
Patch by Adam Turner.
Loading
Loading