aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason McCampbell (Enthought, Inc) <jmccampbell@enthought.com>2012-03-15 16:07:22 -0500
committerHugo Parente Lima <hugo.lima@openbossa.org>2012-04-19 01:16:33 +0200
commit49bc8fbb0803f91d391211356492fba9bc4e68dc (patch)
tree4d57145a1242d60768e49db8076c8983ff1157c6
parentedd5baf707a87cb681fc1300a8942f6f2f348e56 (diff)
Don't clear weakrefs if Python interpreter isn't running1.1.1
Change-Id: I51ba2fcf5f881abb38e9b69b115fb98c536e2146 Reviewed-by: Hugo Parente Lima <hugo.lima@openbossa.org>
-rw-r--r--libshiboken/basewrapper.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/libshiboken/basewrapper.cpp b/libshiboken/basewrapper.cpp
index 382012f..0d2d4b6 100644
--- a/libshiboken/basewrapper.cpp
+++ b/libshiboken/basewrapper.cpp
@@ -206,7 +206,10 @@ SbkObjectType SbkObject_Type = { { {
void SbkDeallocWrapper(PyObject* pyObj)
{
SbkObject* sbkObj = reinterpret_cast<SbkObject*>(pyObj);
- if (sbkObj->weakreflist)
+
+ // Check that Python is still initialized as sometimes this is called by a static destructor
+ // after Python interpeter is shutdown.
+ if (sbkObj->weakreflist && Py_IsInitialized())
PyObject_ClearWeakRefs(pyObj);
// If I have ownership and is valid delete C++ pointer
@@ -232,7 +235,9 @@ void SbkDeallocWrapper(PyObject* pyObj)
void SbkDeallocWrapperWithPrivateDtor(PyObject* self)
{
SbkObject* sbkObj = reinterpret_cast<SbkObject*>(self);
- if (sbkObj->weakreflist)
+ // Check that Python is still initialized as sometimes this is called by a static destructor
+ // after Python interpeter is shutdown.
+ if (sbkObj->weakreflist && Py_IsInitialized())
PyObject_ClearWeakRefs(self);
Shiboken::Object::deallocData(sbkObj, true);