Skip to content

[cpyrt] Import the cppjit module when gThisModule is null - #97

Open
aaronj0 wants to merge 1 commit into
compiler-research:mainfrom
aaronj0:import-on-null-gthismodule
Open

[cpyrt] Import the cppjit module when gThisModule is null#97
aaronj0 wants to merge 1 commit into
compiler-research:mainfrom
aaronj0:import-on-null-gthismodule

Conversation

@aaronj0

@aaronj0 aaronj0 commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

Entering through the public API (Instance_FromVoidPtr) without importing cppjit leaves gThisModule null. With Python already initialized, Initialize() skipped the import and reported success anyway, so CreateScopeProxy() dereferenced null. Import the extension module whenever gThisModule is null.

Entering through the public API (Instance_FromVoidPtr) without importing
cppjit leaves gThisModule null. With Python already initialized,
Initialize() skipped the import and reported success anyway, so
CreateScopeProxy() dereferenced null. Import the extension module
whenever gThisModule is null.
Comment thread src/cpyrt/API.cxx
PyRun_SimpleString(const_cast<char*>("import cppjit"));
// Importing the extension module is what runs the cpyrt initialization
// that sets gThisModule.
if (!cpyrt::gThisModule) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we open an issue tracking the progress of removing global state?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants