Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
bdaef6b
Fix a comment.
ericsnowcurrently Mar 7, 2024
6342635
Add PyInterpreterConfig helpers.
ericsnowcurrently Mar 21, 2024
c48dd00
Add config helpers to _testinternalcapi.
ericsnowcurrently Mar 21, 2024
0796fe9
Use the new helpers in run_in_subinterp_with_config().
ericsnowcurrently Mar 22, 2024
8993b41
Move the PyInterpreterConfig utils to their own file.
ericsnowcurrently Mar 22, 2024
a113017
_PyInterpreterState_ResolveConfig() -> _PyInterpreterConfig_InitFromS…
ericsnowcurrently Mar 22, 2024
fce72b8
_testinternalcapi.new_interpreter_config() -> _xxsubinterpreters.new_…
ericsnowcurrently Mar 22, 2024
c52e484
_testinternalcapi.get_interpreter_config() -> _xxsubinterpreters.get_…
ericsnowcurrently Mar 22, 2024
a2983ce
Call _PyInterpreterState_RequireIDRef() in _interpreters._incref().
ericsnowcurrently Mar 22, 2024
05a081e
_testinternalcapi.interpreter_incref() -> _interpreters._incref()
ericsnowcurrently Mar 23, 2024
8a39bbc
Supporting passing a config to _xxsubinterpreters.create().
ericsnowcurrently Mar 22, 2024
1173cd1
Factor out new_interpreter().
ericsnowcurrently Mar 22, 2024
92c11d3
Fix test_import.
ericsnowcurrently Mar 25, 2024
edda48d
Fix an outdent.
ericsnowcurrently Mar 25, 2024
5f617ed
Call _PyInterpreterState_RequireIDRef() in the right places.
ericsnowcurrently Apr 1, 2024
c504c79
Drop an unnecessary _PyInterpreterState_IDInitref() call.
ericsnowcurrently Apr 1, 2024
8a75c90
Reduce to just the new internal C-API.
ericsnowcurrently Apr 2, 2024
a38cda7
Adjust test_get_config.
ericsnowcurrently Apr 2, 2024
cae0482
Remove trailing whitespace.
ericsnowcurrently Apr 2, 2024
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
_testinternalcapi.interpreter_incref() -> _interpreters._incref()
  • Loading branch information
ericsnowcurrently committed Mar 23, 2024
commit 05a081edecc3085324d8139e1ad28d55247d7292
18 changes: 9 additions & 9 deletions Lib/test/test_capi/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2284,8 +2284,8 @@ def test_linked_lifecycle_does_not_exist(self):
link = _testinternalcapi.link_interpreter_refcount
unlink = _testinternalcapi.unlink_interpreter_refcount
get_refcount = _testinternalcapi.get_interpreter_refcount
incref = _testinternalcapi.interpreter_incref
decref = _testinternalcapi.interpreter_decref
incref = (lambda id: _interpreters._incref(id, implieslink=False))
decref = _interpreters._decref

with self.subTest('never existed'):
interpid = _testinternalcapi.unused_interpreter_id()
Expand Down Expand Up @@ -2339,8 +2339,8 @@ def test_linked_lifecycle_never_linked(self):
exists = _testinternalcapi.interpreter_exists
is_linked = _testinternalcapi.interpreter_refcount_linked
get_refcount = _testinternalcapi.get_interpreter_refcount
incref = _testinternalcapi.interpreter_incref
decref = _testinternalcapi.interpreter_decref
incref = (lambda id: _interpreters._incref(id, implieslink=False))
decref = _interpreters._decref

interpid = _testinternalcapi.new_interpreter()
self.add_interp_cleanup(interpid)
Expand Down Expand Up @@ -2389,8 +2389,8 @@ def test_linked_lifecycle_link_incref_decref(self):
is_linked = _testinternalcapi.interpreter_refcount_linked
link = _testinternalcapi.link_interpreter_refcount
get_refcount = _testinternalcapi.get_interpreter_refcount
incref = _testinternalcapi.interpreter_incref
decref = _testinternalcapi.interpreter_decref
incref = (lambda id: _interpreters._incref(id, implieslink=False))
decref = _interpreters._decref

interpid = _testinternalcapi.new_interpreter()
self.add_interp_cleanup(interpid)
Expand All @@ -2416,7 +2416,7 @@ def test_linked_lifecycle_incref_link(self):
is_linked = _testinternalcapi.interpreter_refcount_linked
link = _testinternalcapi.link_interpreter_refcount
get_refcount = _testinternalcapi.get_interpreter_refcount
incref = _testinternalcapi.interpreter_incref
incref = (lambda id: _interpreters._incref(id, implieslink=False))

interpid = _testinternalcapi.new_interpreter()
self.add_interp_cleanup(interpid)
Expand All @@ -2438,8 +2438,8 @@ def test_linked_lifecycle_link_incref_unlink_decref(self):
link = _testinternalcapi.link_interpreter_refcount
unlink = _testinternalcapi.unlink_interpreter_refcount
get_refcount = _testinternalcapi.get_interpreter_refcount
incref = _testinternalcapi.interpreter_incref
decref = _testinternalcapi.interpreter_decref
incref = (lambda id: _interpreters._incref(id, implieslink=False))
decref = _interpreters._decref

interpid = _testinternalcapi.new_interpreter()
self.add_interp_cleanup(interpid)
Expand Down
24 changes: 0 additions & 24 deletions Modules/_testinternalcapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1557,28 +1557,6 @@ interpreter_refcount_linked(PyObject *self, PyObject *idobj)
Py_RETURN_FALSE;
}

static PyObject *
interpreter_incref(PyObject *self, PyObject *idobj)
{
PyInterpreterState *interp = _PyInterpreterState_LookUpIDObject(idobj);
if (interp == NULL) {
return NULL;
}
_PyInterpreterState_IDIncref(interp);
Py_RETURN_NONE;
}

static PyObject *
interpreter_decref(PyObject *self, PyObject *idobj)
{
PyInterpreterState *interp = _PyInterpreterState_LookUpIDObject(idobj);
if (interp == NULL) {
return NULL;
}
_PyInterpreterState_IDDecref(interp);
Py_RETURN_NONE;
}


static void
_xid_capsule_destructor(PyObject *capsule)
Expand Down Expand Up @@ -1827,8 +1805,6 @@ static PyMethodDef module_functions[] = {
{"link_interpreter_refcount", link_interpreter_refcount, METH_O},
{"unlink_interpreter_refcount", unlink_interpreter_refcount, METH_O},
{"interpreter_refcount_linked", interpreter_refcount_linked, METH_O},
{"interpreter_incref", interpreter_incref, METH_O},
{"interpreter_decref", interpreter_decref, METH_O},
{"compile_perf_trampoline_entry", compile_perf_trampoline_entry, METH_VARARGS},
{"perf_trampoline_set_persist_after_fork", perf_trampoline_set_persist_after_fork, METH_VARARGS},
{"get_crossinterp_data", get_crossinterp_data, METH_VARARGS},
Expand Down