}
_locals=PyDict_New();
PyObject *tmp(PyList_New(0));
- _pickler=PyImport_ImportModuleLevel(const_cast<char *>("pickle"),_globals,_locals,tmp,-1);
+ _pickler=PyImport_ImportModuleLevel(const_cast<char *>("pickle"),_globals,_locals,tmp,0);
}
void DataScopeServerBase::registerToSalomePiDict() const
void DataScopeServerTransaction::pingKey(PyObject *keyObj)
{
- PyObject *cmpObj(getPyCmpFunc());
- if(!keyObj)
- throw Exception("ataScopeServerTransaction::pingKey : Key Object is NULL !");
- PyObject *args(PyTuple_New(2));
- PyTuple_SetItem(args,0,keyObj); Py_XINCREF(keyObj);
std::size_t ii(0);
// this part does nothing except to be sure that in notify key all will be OK.
for(std::list< KeyWaiter *>::iterator it=_waiting_keys.begin();it!=_waiting_keys.end();it++,ii++)
{
PyObject *waitKey((*it)->getKeyPyObj());
- PyTuple_SetItem(args,1,waitKey); Py_XINCREF(waitKey);
- PyObject *res(PyObject_CallObject(cmpObj,args));
+ PyObject *res(PyObject_CallMethodObjArgs(keyObj, PyUnicode_DecodeASCII("__ne__", 6, NULL), waitKey));
if(res==NULL)
{
std::ostringstream oss; oss << "DataScopeServerTransaction::pingKey : for object id #" << ii << " error during cmp(k,wk[i]) !";
throw Exception(oss.str());
}
- PyLong_AsLong(res);
+ PyLong_AsLong(res); // res is bool, but it s ok since __int__ is called
if(PyErr_Occurred())
{
std::ostringstream oss; oss << "DataScopeServerTransaction::pingKey : for object id #" << ii << " error during interpretation of cmp(k,wk[i]) !";
void DataScopeServerTransaction::notifyKey(const std::string& varName, PyObject *keyObj, PyObject *valueObj)
{
- PyObject *cmpObj(getPyCmpFunc());
- if(!keyObj)
- throw Exception("DataScopeServerTransaction::notifyKey : MAIN INTERNAL ERROR ! Key Object is NULL !");
- PyObject *args(PyTuple_New(2));
- PyTuple_SetItem(args,0,keyObj); Py_XINCREF(keyObj);
std::size_t ii(0);
std::list< KeyWaiter *> newList,listOfEltToWakeUp;
for(std::list< KeyWaiter *>::iterator it=_waiting_keys.begin();it!=_waiting_keys.end();it++,ii++)
continue;
}
PyObject *waitKey((*it)->getKeyPyObj());
- PyTuple_SetItem(args,1,waitKey); Py_XINCREF(waitKey);
- PyObject *res(PyObject_CallObject(cmpObj,args));
+ PyObject *res(PyObject_CallMethodObjArgs(keyObj, PyUnicode_DecodeASCII("__ne__", 6, NULL), waitKey));
if(res==NULL)
{
std::ostringstream oss; oss << "DataScopeServerTransaction::notifyKey : MAIN INTERNAL ERROR ! for object id #" << ii << " error during cmp(k,wk[i]) !";
throw Exception(oss.str());
}
- long resCpp(PyLong_AsLong(res));
+ long resCpp(PyLong_AsLong(res)); // res is bool, but it s ok since __int__ is called
if(PyErr_Occurred())
{
std::ostringstream oss; oss << "DataScopeServerTransaction::notifyKey : MAIN INTERNAL ERROR ! for object id #" << ii << " error during interpretation of cmp(k,wk[i]) !";
transactionsCpp[i]->notify();
}
-/*!
- * Returns borrowed reference.
- */
-PyObject *DataScopeServerTransaction::getPyCmpFunc()
-{
- PyObject *builtins(PyDict_GetItemString(_globals,"__builtins__"));//borrowed
- if(builtins==NULL)
- throw Exception("Fail to find reference to builtins !");
- PyObject *builtins2(PyModule_GetDict(builtins));//borrowed
- if(builtins2==NULL)
- throw Exception("Fail to invoke __dict__ on builtins !");
- PyObject *cmpObj(PyDict_GetItemString(builtins2,"cmp"));
- if(cmpObj==NULL)
- throw Exception("Fail to find cmp in __builtins__ !");
- return cmpObj;
-}
-
DataScopeServerTransaction::~DataScopeServerTransaction()
{
}
def __imul__(self,*args):
return self.local_copy().__mul__(*args)
- def __idiv__(self,*args):
- return self.local_copy().__div__(*args)
+ def __itruediv__(self,*args):
+ return self.local_copy().__truediv__(*args)
+
+ def __ifloordiv__(self,*args):
+ return self.local_copy().__floordiv__(*args)
def __add__(self,*args):
return self.local_copy().__add__(*args)
def __mul__(self,*args):
return self.local_copy().__mul__(*args)
- def __div__(self,*args):
- return self.local_copy().__div__(*args)
+ def __floordiv__(self,*args):
+ return self.local_copy().__floordiv__(*args)
+
+ def __truediv__(self,*args):
+ return self.local_copy().__truediv__(*args)
def __pow__(self,*args):
return self.local_copy().__pow__(*args)
def __imod__(self,*args):
return self.local_copy().__mod__(*args)
- def __idiv__(self,*args):
- return self.local_copy().__div__(*args)
+ def __itruediv__(self,*args):
+ return self.local_copy().__truediv__(*args)
+
+ def __ifloordiv__(self,*args):
+ return self.local_copy().__floordiv__(*args)
def __add__(self,*args):
return self.local_copy().__add__(*args)
def __mod__(self,*args):
return self.local_copy().__mod__(*args)
- def __div__(self,*args):
- return self.local_copy().__div__(*args)
-
+ def __truediv__(self,*args):
+ return self.local_copy().__truediv__(*args)
+
+ def __floordiv__(self,*args):
+ return self.local_copy().__floordiv__(*args)
+
def __pow__(self,*args):
return self.local_copy().__pow__(*args)