Skip to content

gh-76785: Improved Subinterpreters Compatibility with 3.12 #115424

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 20 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
Work around a ref leak.
  • Loading branch information
ericsnowcurrently committed Feb 13, 2024
commit f17b29baeebf9d34ee4c56a16d55b67e161921cd
10 changes: 10 additions & 0 deletions Python/crossinterp.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

static int init_exceptions(PyInterpreterState *);
static void fini_exceptions(PyInterpreterState *);
static int _init_not_shareable_error_type(PyInterpreterState *);
static void _fini_not_shareable_error_type(PyInterpreterState *);
static PyObject * _get_not_shareable_error_type(PyInterpreterState *);
#include "crossinterp_exceptions.h"

Expand Down Expand Up @@ -1645,6 +1647,11 @@ _PyXI_Init(PyInterpreterState *interp)
// Initialize the XID lookup state (e.g. registry).
xid_lookup_init(interp);

// Initialize exceptions (heap types).
if (_init_not_shareable_error_type(interp) < 0) {
return _PyStatus_ERR("failed to initialize NotShareableError");
}

return _PyStatus_OK();
}

Expand All @@ -1654,6 +1661,9 @@ _PyXI_Init(PyInterpreterState *interp)
void
_PyXI_Fini(PyInterpreterState *interp)
{
// Finalize exceptions (heap types).
_fini_not_shareable_error_type(interp);

// Finalize the XID lookup state (e.g. registry).
xid_lookup_fini(interp);
}
Expand Down
7 changes: 3 additions & 4 deletions Python/crossinterp_exceptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,16 @@ init_exceptions(PyInterpreterState *interp)
}

// heap types
if (_init_not_shareable_error_type(interp) < 0) {
return -1;
}
// We would call _init_not_shareable_error_type() here too,
// but that leads to ref leaks

return 0;
}

static void
fini_exceptions(PyInterpreterState *interp)
{
_fini_not_shareable_error_type(interp);
// Likewise with _fini_not_shareable_error_type().
_PyStaticType_Dealloc(interp, &_PyExc_InterpreterNotFoundError);
_PyStaticType_Dealloc(interp, &_PyExc_InterpreterError);
}
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