Skip to content

gh-76785: Improved Subinterpreters Compatibility with 3.12 (2/2) #126707

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

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Add state init/fini funcs.
  • Loading branch information
ericsnowcurrently committed Nov 11, 2024
commit ad7cd0d9744cc2254e0575c210533d4e30a8ae3b
7 changes: 7 additions & 0 deletions Include/internal/pycore_crossinterp.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,17 @@ typedef struct {
#define _PyXI_GET_GLOBAL_STATE(interp) (&(interp)->runtime->xi)
#define _PyXI_GET_STATE(interp) (&(interp)->xi)

#ifndef Py_BUILD_CORE_MODULE
extern PyStatus _PyXI_Init(PyInterpreterState *interp);
extern void _PyXI_Fini(PyInterpreterState *interp);
extern PyStatus _PyXI_InitTypes(PyInterpreterState *interp);
extern void _PyXI_FiniTypes(PyInterpreterState *interp);
#endif // Py_BUILD_CORE_MODULE

int _Py_xi_global_state_init(_PyXI_global_state_t *);
void _Py_xi_global_state_fini(_PyXI_global_state_t *);
int _Py_xi_state_init(_PyXI_state_t *);
void _Py_xi_state_fini(_PyXI_state_t *);


/***************************/
Expand Down
43 changes: 43 additions & 0 deletions Python/crossinterp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1868,6 +1868,49 @@ _PyXI_FiniTypes(PyInterpreterState *interp)
fini_static_exctypes(&_PyXI_GET_STATE(interp)->exceptions, interp);
}

int
_Py_xi_global_state_init(_PyXI_global_state_t *state)
{
xid_lookup_init(&state->data_lookup);
return 0;
}

void
_Py_xi_global_state_fini(_PyXI_global_state_t *state)
{
xid_lookup_fini(&state->data_lookup);
}

int
_Py_xi_state_init(_PyXI_state_t *state)
{
PyInterpreterState *interp = _PyInterpreterState_GET();

xid_lookup_init(&state->data_lookup);

// Initialize exceptions.
if (init_exceptions(interp) < 0) {
return -1;
}
if (_init_not_shareable_error_type(state) < 0) {
return -1;
}
return 0;
}

void
_Py_xi_state_fini(_PyXI_state_t *state)
{
PyInterpreterState *interp = _PyInterpreterState_GET();

// Finalize exceptions.
_fini_not_shareable_error_type(state);
fini_exceptions(interp);

// Finalize the XID lookup state (e.g. registry).
xid_lookup_fini(&state->data_lookup);
}


/*************/
/* other API */
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy