Skip to content

Commit 0df4112

Browse files
Merge pull request #11 from LIHPC-Computational-Geometry/preinitialize-fix
Version 6.4.4. QtPython::preInitialize throws an exception if called …
2 parents 21a47f1 + 21436e4 commit 0df4112

File tree

3 files changed

+25
-5
lines changed

3 files changed

+25
-5
lines changed

cmake/version.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
# Pour la bibliothèque QtPython :
66
set (QT_PYTHON_MAJOR_VERSION "6")
77
set (QT_PYTHON_MINOR_VERSION "4")
8-
set (QT_PYTHON_RELEASE_VERSION "3")
8+
set (QT_PYTHON_RELEASE_VERSION "4")
99
set (QT_PYTHON_VERSION ${QT_PYTHON_MAJOR_VERSION}.${QT_PYTHON_MINOR_VERSION}.${QT_PYTHON_RELEASE_VERSION})
1010

1111
# Pour la bibliothèque QtPython3 :
1212
set (QT_PYTHON_3_MAJOR_VERSION "6")
1313
set (QT_PYTHON_3_MINOR_VERSION "4")
14-
set (QT_PYTHON_3_RELEASE_VERSION "3")
14+
set (QT_PYTHON_3_RELEASE_VERSION "4")
1515
set (QT_PYTHON_3_VERSION ${QT_PYTHON_3_MAJOR_VERSION}.${QT_PYTHON_3_MINOR_VERSION}.${QT_PYTHON_3_RELEASE_VERSION})
1616

src/QtPython3/QtPython.cpp

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,23 @@ QtPython::~QtPython ( )
190190

191191
void QtPython::preInitialize ( ) // CP v 5.1.0
192192
{
193-
// A faire avant Py_Initialize :
194-
if (-1 == PyImport_AppendInittab ("redirector", PyInit_redirector))
195-
throw Exception ("Echec de l'importation du module redirector par la console Python.");
193+
static bool preInitialized = false; // v 6.4.4
194+
195+
if (false == preInitialized)
196+
{
197+
// A faire avant Py_Initialize :
198+
if (false == Py_IsInitialized ( ))
199+
{
200+
if (-1 == PyImport_AppendInittab ("redirector", PyInit_redirector))
201+
throw Exception ("Echec de l'importation du module redirector par la console Python.");
202+
}
203+
else
204+
// v 6.4.4. Eviter (python 3.12.5) : Fatal Python error: PyImport_AppendInittab: PyImport_AppendInittab() may not be called after Py_Initialize()
205+
// Python runtime state: initialized
206+
throw Exception ("QtPython::preInitialize doit être appelé avant Py_Initialize. PyImport_AppendInittab non appelé car l'application planterait. La console python ne devrait pas fonctionner correctement.");
207+
208+
preInitialized = true;
209+
} // if (false == preInitialized)
196210
} // QtPython::preInitialize
197211

198212

versions.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
Version 6.4.4 : 20/11/24
2+
===============
3+
4+
QtPython::preInitialize l�ve une exception si appel�e pour la premi�re fois apr�s Py_Initialize en vue d'�viter un fatal error de python 3.
5+
6+
17
Version 6.4.3 : 04/10/24
28
===============
39

0 commit comments

Comments
 (0)