Reviewer suggestions

This commit is contained in:
Aaron Gokaslan 2022-02-20 12:40:27 -05:00
parent bdcd95aa73
commit 225dbae67e
3 changed files with 11 additions and 15 deletions

View File

@ -402,7 +402,8 @@ jobs:
-DCMAKE_CXX_STANDARD=11 \
-DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)") \
-DCMAKE_CXX_FLAGS="-Wc,--pending_instantiations=0" \
-DPYBIND11_TEST_FILTER="test_smart_ptr.cpp;test_virtual_functions.cpp"\
-DPYBIND11_TEST_FILTER="test_smart_ptr.cpp;test_virtual_functions.cpp" \
-DCMAKE_BUILD_TYPE=Debug
# Building before installing Pip should produce a warning but not an error
- name: Build

View File

@ -469,22 +469,23 @@ PYBIND11_NOINLINE bool isinstance_generic(handle obj, const std::type_info &tp)
return isinstance(obj, type);
}
PYBIND11_NOINLINE std::string error_string(PyObject *type, PyObject *value, PyObject *trace) {
if (!type) {
PYBIND11_NOINLINE std::string
error_string(PyObject *exc_type, PyObject *exc_value, PyObject *exc_trace) {
if (!exc_type) {
PyErr_SetString(PyExc_RuntimeError, "Unknown internal error occurred");
return "Unknown internal error occurred";
}
auto result = handle(type).attr("__name__").cast<std::string>();
auto result = handle(exc_type).attr("__name__").cast<std::string>();
result += ": ";
if (value) {
result += (std::string) str(value);
if (exc_value) {
result += (std::string) str(exc_value);
}
if (trace) {
if (exc_trace) {
#if !defined(PYPY_VERSION)
auto *tb = (PyTracebackObject *) trace;
auto *tb = (PyTracebackObject *) exc_trace;
// Get the deepest trace possible.
while (tb->tb_next) {
@ -507,7 +508,7 @@ PYBIND11_NOINLINE std::string error_string(PyObject *type, PyObject *value, PyOb
frame = frame->f_back;
Py_DECREF(f_code);
}
#endif
#endif //! defined(PYPY_VERSION)
}
return result;
@ -517,9 +518,6 @@ PYBIND11_NOINLINE std::string error_string() {
error_scope scope; // Preserve error state.
if (scope.type) {
PyErr_NormalizeException(&scope.type, &scope.value, &scope.trace);
/*if (scope.trace != nullptr){
PyErr_SetTraceback(scope.value, scope.trace);
}*/
}
return error_string(scope.type, scope.value, scope.trace);
}

View File

@ -387,9 +387,6 @@ public:
PyErr_Fetch(&m_type.ptr(), &m_value.ptr(), &m_trace.ptr());
if (m_type) {
PyErr_NormalizeException(&m_type.ptr(), &m_value.ptr(), &m_trace.ptr());
/*if (m_trace) {
PyException_SetTraceback(m_value.ptr(), m_trace.ptr());
}*/
}
}