From 1476c26bf08c95aef7bdfb41977c12e45cb152c7 Mon Sep 17 00:00:00 2001 From: Damien Marchal Date: Thu, 16 Sep 2021 13:13:54 +0200 Subject: [PATCH] [Bindings/Sofa] Fix the getPythonCallingPointXXXX method in Sofa.__init__.py Because it was not properly returning the callpoint. --- Plugin/src/SofaPython3/PythonEnvironment.cpp | 2 +- bindings/Sofa/package/__init__.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Plugin/src/SofaPython3/PythonEnvironment.cpp b/Plugin/src/SofaPython3/PythonEnvironment.cpp index 0cf17cb7d..021e4869f 100644 --- a/Plugin/src/SofaPython3/PythonEnvironment.cpp +++ b/Plugin/src/SofaPython3/PythonEnvironment.cpp @@ -467,7 +467,7 @@ std::string PythonEnvironment::getStackAsString() std::string PythonEnvironment::getPythonCallingPointString() { - return py::cast(py::eval("Sofa.getPythonCallingPointAsString()")); + return py::cast(getStaticData()->m_sofamodule.attr("getPythonCallingPointAsString")()); } sofa::helper::logging::FileInfo::SPtr PythonEnvironment::getPythonCallingPointAsFileInfo() diff --git a/bindings/Sofa/package/__init__.py b/bindings/Sofa/package/__init__.py index 305889e90..0281d2306 100644 --- a/bindings/Sofa/package/__init__.py +++ b/bindings/Sofa/package/__init__.py @@ -93,14 +93,14 @@ def getPythonCallingPointAsString(): """returns the last entry with an "informal" formatting. """ ## we exclude the first level in the stack because it is the getStackForSofa() function itself. - ss=inspect.stack()[-1:] + ss=inspect.stack()[1:2] return formatStackForSofa(ss) def getPythonCallingPoint(): - """returns the tupe with closest filename & line. """ + """returns the tuple with closest filename & line. """ ## we exclude the first level in the stack because it is the getStackForSofa() function itself. - ss=inspect.stack()[1] + ss=inspect.stack()[1:2] tmp=(os.path.abspath(ss[1]), ss[2]) return tmp