Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions docs/mainpage.dox.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,8 @@ PythonProgram::setSaveObjectCallback(callback);
@section pythonreleasenotes python Module Release Notes

@subsection python_1_0_2 python Module Version 1.0.2
- fixed issues handling the case when the python module is initialized with no Program context
(<a href="https://github.com/qorelanguage/qore/issues/4153">issue 4153</a>)
- fixed a bug handling Python constructors in classes derived from Qore or Java classes where the constructor code
accesses Qore or Java class members or methods before initializing the class
(<a href="https://github.com/qorelanguage/qore/issues/4141">issue 4141</a>)
Expand Down
10 changes: 8 additions & 2 deletions src/python-module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,12 @@ static void python_module_ns_init(QoreNamespace* rns, QoreNamespace* qns) {
if (!pgm->getExternalData(QORE_PYTHON_MODULE_NAME)) {
QoreNamespace* pyns = PNS.copy();
rns->addNamespace(pyns);
pgm->setExternalData(QORE_PYTHON_MODULE_NAME, new QorePythonProgram(pgm, pyns));
// issue #4153: in case we only have the calling context here
ExceptionSink xsink;
QoreExternalProgramContextHelper pch(&xsink, pgm);
if (!xsink) {
pgm->setExternalData(QORE_PYTHON_MODULE_NAME, new QorePythonProgram(pgm, pyns));
}
}

assert(!PyGILState_Check());
Expand Down Expand Up @@ -363,7 +368,8 @@ static void python_module_parse_cmd(const QoreString& cmd, ExceptionSink* xsink)
if (!pypgm) {
QoreNamespace* pyns = PNS.copy();
pgm->getRootNS()->addNamespace(pyns);
pgm->setExternalData(QORE_PYTHON_MODULE_NAME, new QorePythonProgram(pgm, pyns));
pypgm = new QorePythonProgram(pgm, pyns);
pgm->setExternalData(QORE_PYTHON_MODULE_NAME, pypgm);
pgm->addFeature(QORE_PYTHON_MODULE_NAME);
}

Expand Down