MCPcopy Create free account
hub / github.com/mhammond/pywin32 / InitMainInterp

Method InitMainInterp

isapi/src/PythonEng.cpp:61–103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59}
60
61bool CPythonEngine::InitMainInterp(void)
62{
63 // ensure only 1 engine/thread initialises this only
64 CSLock l(m_initLock);
65 if (!m_haveInit) {
66 PyGILState_STATE old_state;
67 if (Py_IsInitialized())
68 old_state = PyGILState_Ensure();
69 else {
70 Py_Initialize();
71 old_state = PyGILState_UNLOCKED;
72 }
73 PyEval_InitThreads();
74
75 if (!g_IsFrozen) {
76 TCHAR *dll_path = GetModulePath();
77 AddToPythonPath(dll_path);
78 free(dll_path);
79 PyErr_Clear();
80 }
81
82 // isapidllhandle to match dllhandle, frozendllhandle, etc :) Also a
83 // nice way for a program to know they are in an ISAPI context.
84 PyObject *obh = PyLong_FromVoidPtr(g_hInstance);
85 PySys_SetObject("isapidllhandle", obh);
86 Py_XDECREF(obh);
87 // Locate the special exception we use to trigger a reload.
88 PyObject *isapi_package = PyImport_ImportModule("isapi");
89 if (isapi_package)
90 m_reload_exception = PyObject_GetAttrString(isapi_package,
91 "InternalReloadException");
92 Py_XDECREF(isapi_package);
93
94 // ready our types.
95 InitExtensionTypes();
96 InitFilterTypes();
97
98 PyGILState_Release(old_state);
99 FindModuleName();
100 m_haveInit = true;
101 }
102 return true;
103}
104
105void CPythonEngine::FindModuleName()
106{

Callers 1

InitMethod · 0.80

Calls 3

GetModulePathFunction · 0.85
InitExtensionTypesFunction · 0.85
InitFilterTypesFunction · 0.85

Tested by

no test coverage detected