Skip to content
Permalink
Browse files

Merge pull request #1347 from wxWidgets/errcheck-virtual-methods

Check for Python errors upon return from overloaded virtual methods
  • Loading branch information...
RobinD42 committed Sep 6, 2019
2 parents 46ca3db + 059e1be commit 0e817cee5916a8c06695ac2f787c761e02f49144
Showing with 27 additions and 6 deletions.
  1. +6 −1 etg/dataview.py
  2. +13 −3 etg/grid.py
  3. +6 −1 etg/propgrideditors.py
  4. +2 −1 etg/taskbar.py
@@ -279,7 +279,12 @@ def _fixupTypeParam(klass):
# an out parameter.
m.virtualCatcherCode = """\
PyObject *sipResObj = sipCallMethod(&sipIsErr, sipMethod, "D", editor, sipType_wxWindow, NULL);
if (sipResObj == Py_None) {
if (sipResObj == NULL) {
if (PyErr_Occurred())
PyErr_Print();
sipRes = false;
}
else if (sipResObj == Py_None) {
sipRes = false;
} else {
sipRes = true;
@@ -243,14 +243,19 @@ def fixEditorClass(name):
result = sipCallMethod(0, sipMethod, "iiDN", row, col,
const_cast<wxGrid *>(grid),sipType_wxGrid,NULL,
new wxString(oldval),sipType_wxString,NULL);
if (result == Py_None) {
if (result == NULL) {
if (PyErr_Occurred())
PyErr_Print();
sipRes = false;
}
else if (result == Py_None) {
sipRes = false;
}
else {
sipRes = true;
*newval = Py2wxString(result);
}
Py_DECREF(result);
Py_XDECREF(result);
""" if pureVirtual else "", # only used with the base class
)

@@ -337,7 +342,12 @@ def fixEditorClass(name):
m.virtualCatcherCode = """\
// virtualCatcherCode for GridTableBase.GetValue
PyObject *result = sipCallMethod(&sipIsErr, sipMethod, "ii", row, col);
if (result == Py_None) {
if (result == NULL) {
if (PyErr_Occurred())
PyErr_Print();
sipRes = "";
}
else if (result == Py_None) {
sipRes = "";
}
else {
@@ -57,7 +57,12 @@ def run():
PyObject *sipResObj = sipCallMethod(&sipIsErr, sipMethod, "DD",
property, sipType_wxPGProperty, NULL,
ctrl, sipType_wxWindow, NULL);
if (sipResObj == Py_None) {
if (sipResObj == NULL) {
if (PyErr_Occurred())
PyErr_Print();
sipRes = false;
}
else if (sipResObj == Py_None) {
sipRes = false;
} else if (sipResObj && !sipIsErr) {
sipParseResult(&sipIsErr, sipMethod, sipResObj, "(bH5)", &sipRes, sipType_wxPGVariant, &variant);
@@ -60,7 +60,8 @@ def run():
method.virtualCatcherCode = """\
// VirtualCatcherCode for wxTaskBarIcon.CreatePopupMenu
PyObject *sipResObj = sipCallMethod(0, sipMethod, "");
sipParseResult(0, sipMethod, sipResObj, "H0", sipType_wxMenu, &sipRes);
if (!sipResObj || sipParseResult(0, sipMethod, sipResObj, "H0", sipType_wxMenu, &sipRes) < 0)
PyErr_Print();
if (sipRes) {
sipTransferTo(sipResObj, Py_None);
}

0 comments on commit 0e817ce

Please sign in to comment.
You can’t perform that action at this time.