Salome HOME
updated copyright message
[modules/gui.git] / tools / PyInterp / src / PyInterp_Utils.h
index 8d6ce8c638acbc9b7dec862399d32a1e9b860aad..73ca89a686eadf74ed24b2b1329032d10cf70f3a 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2023  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
   #include <iostream>
 #endif
 
+#if PY_VERSION_HEX < 0x03050000
+static char*
+Py_EncodeLocale(const wchar_t *arg, size_t *size)
+{
+       return _Py_wchar2char(arg, size);
+}
+static wchar_t*
+Py_DecodeLocale(const char *arg, size_t *size)
+{
+       return _Py_char2wchar(arg, size);
+}
+#endif
+
 /**
  * \class PyLockWrapper
  * \brief Python GIL wrapper.
@@ -38,7 +51,7 @@
  * Utility class wrapping the Python GIL acquisition. This makes use of the high level
  * API (PyGILState_Ensure and PyGILState_Release), and is hence compatible with only
  * one running Python interpreter (no call to Py_NewInterpreter()).
- * When the class is instanciated the lock is acquired. It is released at destruction time.
+ * When the class is instantiated the lock is acquired. It is released at destruction time.
  * Copy construction (and hence assignation) is forbidden.
  */
 class PYINTERP_EXPORT PyLockWrapper
@@ -60,6 +73,7 @@ public:
   ~PyLockWrapper()
   {
     PyThreadState* _currState = PyGILState_GetThisThreadState();
+    (void)_currState;
 #ifdef _DEBUG_
     if (_currState != _state)
     {
@@ -101,6 +115,14 @@ public:
   {
     Py_XDECREF(myObject);
     myObject = theObjWrapper->myObject;
+    Py_XINCREF(myObject);
+    return *this;
+  }
+  PyObjWrapper& operator=(const PyObjWrapper& theObjWrapper)
+  {
+    Py_XDECREF(myObject);
+    myObject = theObjWrapper.myObject;
+    Py_XINCREF(myObject);
     return *this;
   }
 };