Salome HOME
Merge commit 'f709219506b7cd587e94abc5ebed18d629df92d8'
[modules/shaper.git] / src / InitializationPlugin / InitializationPlugin_PyInterp.cpp
index 5e1699933ef71259c2e4fcf64500c8a3bf339da1..3a5b608dd9aeca6671839bb06a1a5b21b1cc7740 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2021  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2022  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -24,6 +24,7 @@
 #include <string>
 #include <stdexcept>
 #include <clocale>
+#include <Python.h>
 
 InitializationPlugin_PyInterp::InitializationPlugin_PyInterp()
 : PyInterp_Interp()
@@ -118,7 +119,11 @@ std::list<std::wstring> InitializationPlugin_PyInterp::compile(const std::wstrin
   }
 
   PyCodeObject* aCodeObj = (PyCodeObject*) aCodePyObj;
+#if PY_VERSION_HEX >= 0x030B0000
+  std::string aCodeName(PyBytes_AsString(PyObject_GetAttrString((PyObject *)(aCodeObj), "co_code")));
+#else
   std::string aCodeName(PyBytes_AsString(aCodeObj->co_code));
+#endif
   // co_names should be tuple, but can be changed in modern versions of python (>2.7.3)
   if(!PyTuple_Check(aCodeObj->co_names)) {
     return aResult;
@@ -232,26 +237,6 @@ bool InitializationPlugin_PyInterp::initContext()
   _local_context = PyDict_New();
   Py_INCREF(_local_context);
 
-  // to avoid "help()" hang in the python console
-  const static char* aHelpTxt = "def help(): print(\"Available modules:\\n"
-    "  salome.shaper.model : higher level access to features and data model\\n"
-    "  BuildAPI            : Build plugin features allowing to build shapes\\n"
-    "  ConfigAPI           : configuration management: preferences and XML properties\\n"
-    "  ConstructionAPI     : Construction plugin for auxiliary features creation\\n"
-    "  EventsAPI           : application events receiving and emitting manager\\n"
-    "  ExchangeAPI         : Exchange plugin with import/export features\\n"
-    "  FeaturesAPI         : Features plugin with general 3D features\\n"
-    "  GeomAlgoAPI         : geometrical algorithms\\n"
-    "  GeomAPI             : geometrical data structures\\n"
-    "  GeomDataAPI         : specific geometrical data structures stored in the data model\\n"
-    "  ModelAPI            : general low-level interface to access data model\\n"
-    "  ModelHighAPI        : general high-level interface to access data model\\n"
-    "  ParametersAPI       : Parameters plugin for parameters feature management\\n"
-    "  PartSetAPI          : PartSet plugin for management Parts features\\n"
-    "  SketchAPI           : Sketch plugin with all sketch features\")";
-
-  PyRun_SimpleString(aHelpTxt);
-
   return PyRun_SimpleString("from math import *") == 0;
 }