mirror of
https://github.com/python/cpython.git
synced 2025-11-01 22:21:35 +00:00
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().
This commit is contained in:
parent
4c20f46fa0
commit
cd9536a087
14 changed files with 322 additions and 177 deletions
|
|
@ -1278,13 +1278,8 @@ object_is_shareable(PyObject *self, PyObject *args, PyObject *kwds)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
PyInterpreterState *interp = PyInterpreterState_Get();
|
||||
_PyXIData_lookup_context_t ctx;
|
||||
if (_PyXIData_GetLookupContext(interp, &ctx) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (_PyObject_CheckXIData(&ctx, obj) == 0) {
|
||||
PyThreadState *tstate = _PyThreadState_GET();
|
||||
if (_PyObject_CheckXIData(tstate, obj) == 0) {
|
||||
Py_RETURN_TRUE;
|
||||
}
|
||||
PyErr_Clear();
|
||||
|
|
@ -1577,14 +1572,9 @@ The 'interpreters' module provides a more convenient interface.");
|
|||
static int
|
||||
module_exec(PyObject *mod)
|
||||
{
|
||||
PyInterpreterState *interp = PyInterpreterState_Get();
|
||||
PyThreadState *tstate = _PyThreadState_GET();
|
||||
module_state *state = get_module_state(mod);
|
||||
|
||||
_PyXIData_lookup_context_t ctx;
|
||||
if (_PyXIData_GetLookupContext(interp, &ctx) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
#define ADD_WHENCE(NAME) \
|
||||
if (PyModule_AddIntConstant(mod, "WHENCE_" #NAME, \
|
||||
_PyInterpreterState_WHENCE_##NAME) < 0) \
|
||||
|
|
@ -1606,7 +1596,8 @@ module_exec(PyObject *mod)
|
|||
if (PyModule_AddType(mod, (PyTypeObject *)PyExc_InterpreterNotFoundError) < 0) {
|
||||
goto error;
|
||||
}
|
||||
if (PyModule_AddType(mod, (PyTypeObject *)ctx.PyExc_NotShareableError) < 0) {
|
||||
PyObject *exctype = _PyXIData_GetNotShareableErrorType(tstate);
|
||||
if (PyModule_AddType(mod, (PyTypeObject *)exctype) < 0) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue