From c63a0cb34edf15485f4dbf86d9c4922e10bc8a4e Mon Sep 17 00:00:00 2001 From: Graham Dumpleton Date: Sun, 11 Aug 2013 21:18:55 +0800 Subject: [PATCH] Cannot cache Python objects as static data as causes problems when have multiple interpreters. --- src/_wrappers.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/_wrappers.c b/src/_wrappers.c index 20e2459..2fdaed9 100644 --- a/src/_wrappers.c +++ b/src/_wrappers.c @@ -304,7 +304,7 @@ static PyObject *WraptWrapperBase_getattro( static int WraptWrapperBase_setattro( WraptWrapperBaseObject *self, PyObject *name, PyObject *value) { - static PyObject *self_prefix = NULL; + PyObject *self_prefix = NULL; PyObject *match = NULL; @@ -313,16 +313,16 @@ static int WraptWrapperBase_setattro( return -1; } - if (!self_prefix) { #if PY_MAJOR_VERSION >= 3 - self_prefix = PyUnicode_FromString("_self_"); + self_prefix = PyUnicode_FromString("_self_"); #else - self_prefix = PyString_FromString("_self_"); + self_prefix = PyString_FromString("_self_"); #endif - } match = PyEval_CallMethod(name, "startswith", "(O)", self_prefix); + Py_DECREF(self_prefix); + if (match == Py_True) { Py_DECREF(match);