Mod: change error text of Python wrapper when trying to access deleted view

This commit is contained in:
wmayer
2021-11-21 19:57:21 +01:00
parent fad2fd9568
commit 9bfab4262f
3 changed files with 15 additions and 6 deletions

View File

@@ -504,8 +504,11 @@ Py::Object SheetViewPy::repr()
// appear for SheetViewPy, too.
Py::Object SheetViewPy::getattr(const char * attr)
{
if (!getSheetViewPtr())
throw Py::RuntimeError("Cannot print representation of deleted object");
if (!getSheetViewPtr()) {
std::ostringstream s_out;
s_out << "Cannot access attribute '" << attr << "' of deleted object";
throw Py::RuntimeError(s_out.str());
}
std::string name( attr );
if (name == "__dict__" || name == "__class__") {
Py::Dict dict_self(BaseType::getattr("__dict__"));

View File

@@ -1415,8 +1415,11 @@ Py::Object MDIViewPagePy::repr()
// appear for SheetViewPy, too.
Py::Object MDIViewPagePy::getattr(const char * attr)
{
if (!getMDIViewPagePtr())
throw Py::RuntimeError("Cannot print representation of deleted object");
if (!getMDIViewPagePtr()) {
std::ostringstream s_out;
s_out << "Cannot access attribute '" << attr << "' of deleted object";
throw Py::RuntimeError(s_out.str());
}
std::string name( attr );
if (name == "__dict__" || name == "__class__") {
Py::Dict dict_self(BaseType::getattr("__dict__"));

View File

@@ -240,8 +240,11 @@ Py::Object BrowserViewPy::repr()
// appear for SheetViewPy, too.
Py::Object BrowserViewPy::getattr(const char * attr)
{
if (!getBrowserViewPtr())
throw Py::RuntimeError("Cannot print representation of deleted object");
if (!getBrowserViewPtr()) {
std::ostringstream s_out;
s_out << "Cannot access attribute '" << attr << "' of deleted object";
throw Py::RuntimeError(s_out.str());
}
std::string name( attr );
if (name == "__dict__" || name == "__class__") {
Py::Dict dict_self(BaseType::getattr("__dict__"));