Skip to content

Commit

Permalink
Fixup error reporting for python3
Browse files Browse the repository at this point in the history
  • Loading branch information
noelpower committed Feb 20, 2019
1 parent 80420ee commit b9ea52c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
7 changes: 7 additions & 0 deletions package/yast2-python-bindings.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Wed Feb 20 14:41:28 UTC 2019 - nopower@suse.com

- Fix python3 bindings error showning 'unexpect exception' and no
trace information for errors; (bsc# 1126112).
- 4.0.9

-------------------------------------------------------------------
Fri Jan 18 17:39:23 UTC 2019 - dmulder@suse.com, nopower@suse.com

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-python-bindings.spec
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
%endif

Name: yast2-python-bindings
Version: 4.0.8
Version: 4.0.9
Release: 0
Summary: Python bindings for the YaST platform
License: GPL-2.0-only
Expand Down
16 changes: 8 additions & 8 deletions src/YPython.cc
Original file line number Diff line number Diff line change
Expand Up @@ -491,9 +491,9 @@ string YPython::PyErrorHandler()
pystring = NULL;
if (errobj != NULL &&
(pystring = PyObject_Str(errobj)) != NULL && /* str(object) */
(PyString_Check(pystring))
(PyStr_Check(pystring))
) {
result += PyString_AsString(pystring);
result += PyStr_AsString(pystring);
} else {
result += "<unknown exception type>";
}
Expand All @@ -503,9 +503,9 @@ string YPython::PyErrorHandler()
pystring = NULL;
if (errdata != NULL &&
(pystring = PyObject_Str(errdata)) != NULL &&
(PyString_Check(pystring))
(PyStr_Check(pystring))
) {
result += PyString_AsString(pystring);
result += PyStr_AsString(pystring);
} else {
result += "<unknown exception value>";
}
Expand All @@ -514,9 +514,9 @@ string YPython::PyErrorHandler()
result +="; error traceback: ";

pystring = NULL;
if (errdata != NULL &&
if (errtraceback != NULL &&
(pystring = PyObject_Str(errtraceback)) != NULL &&
(PyString_Check(pystring))
(PyStr_AsString(pystring))
) {
PyObject *mod = PyImport_ImportModule("traceback");
if (mod) {
Expand All @@ -533,13 +533,13 @@ string YPython::PyErrorHandler()
traceStr = PyUnicode_Join(newline, meth_result);
}
if (traceStr) {
result += PyString_AsString(traceStr);
result += PyStr_AsString(traceStr);
}
Py_XDECREF(meth_result);
Py_XDECREF(traceStr);
Py_XDECREF(newline);
} else {
result += PyString_AsString(pystring);
result += PyStr_AsString(pystring);
}
} else {
result += "<unknown exception traceback>";
Expand Down

0 comments on commit b9ea52c

Please sign in to comment.