Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Add try/catch around python function calls. #5678
Conversation
|
Kindly requesting a review. |
shelhamer
added the
Python
label
Jun 28, 2017
|
Hey @hgaiser, thanks for trying to make pycaffe friendlier but it seems the change is failing the exception test for continuous integration. Please have a look at that first. |
|
@shelhamer Apparently PyErr_Print clears the error indicator, so I changed it to fetch and restore the error indicator. It's a bit ugly if you ask me (PyErr_Print shouldn't clear the error indicator IMO) but apparently this is how it is intended by the Python people. That was the cause of the RuntimeError not being thrown in Python, so the test case works now. We'll see what Travis has to say about it :) |
|
Seems two of the Travis jobs failed, but they appear unrelated to my changes. @shelhamer can you verify if these are something for me to be concerned about ? |
|
Sorry, on second look I'm confused by the need for this PR. When I raise an exception from a Python layer it is properly reported. Under what conditions do you encounter the error in this issue? What version of Python and boost::python are you using?
Those assertion failures are very strange. I have not seen them elsewhere, but they do not seem related to this PR either. I'll try to have a closer look soon. |
|
Try with the following prototxt:
And corresponding python layer:
Place them in the same dir and run something like this:
The error I'm seeing with master is:
The error I am seeing with this PR is:
For the record, I'm using python 3.6 and boost 1.64. |
|
@shelhamer any update? |
hgaiser commentedJun 9, 2017
Every Python call from c++ should be guarded with a try/catch to print its Python error. Previously a Python exception would only print :
With this PR, caffe will print the entire stack trace where the exception occurred, making debugging 100x easier ;)