@@ -470,73 +470,6 @@ PYBIND11_NOINLINE bool isinstance_generic(handle obj, const std::type_info &tp)
470470 return isinstance (obj, type);
471471}
472472
473- PYBIND11_NOINLINE std::string error_string (const char *called) {
474- error_scope scope; // Fetch error state (will be restored when this function returns).
475- if (scope.type == nullptr ) {
476- if (called == nullptr ) {
477- called = " pybind11::detail::error_string()" ;
478- }
479- pybind11_fail (" Internal error: " + std::string (called)
480- + " called while Python error indicator not set." );
481- }
482-
483- PyErr_NormalizeException (&scope.type , &scope.value , &scope.trace );
484- if (scope.trace != nullptr ) {
485- PyException_SetTraceback (scope.value , scope.trace );
486- }
487-
488- std::string errorString;
489- if (scope.type ) {
490- errorString += handle (scope.type ).attr (" __name__" ).cast <std::string>();
491- errorString += " : " ;
492- }
493- if (scope.value ) {
494- errorString += (std::string) str (scope.value );
495- }
496-
497- #if !defined(PYPY_VERSION)
498- if (scope.trace ) {
499- auto *trace = (PyTracebackObject *) scope.trace ;
500-
501- /* Get the deepest trace possible */
502- while (trace->tb_next ) {
503- trace = trace->tb_next ;
504- }
505-
506- PyFrameObject *frame = trace->tb_frame ;
507- Py_XINCREF (frame);
508- errorString += " \n\n At:\n " ;
509- while (frame) {
510- # if PY_VERSION_HEX >= 0x030900B1
511- PyCodeObject *f_code = PyFrame_GetCode (frame);
512- # else
513- PyCodeObject *f_code = frame->f_code ;
514- Py_INCREF (f_code);
515- # endif
516- int lineno = PyFrame_GetLineNumber (frame);
517- errorString += " " ;
518- errorString += handle (f_code->co_filename ).cast <std::string>();
519- errorString += ' (' ;
520- errorString += std::to_string (lineno);
521- errorString += " ): " ;
522- errorString += handle (f_code->co_name ).cast <std::string>();
523- errorString += ' \n ' ;
524- Py_DECREF (f_code);
525- # if PY_VERSION_HEX >= 0x030900B1
526- auto *b_frame = PyFrame_GetBack (frame);
527- # else
528- auto *b_frame = frame->f_back ;
529- Py_XINCREF (b_frame);
530- # endif
531- Py_DECREF (frame);
532- frame = b_frame;
533- }
534- }
535- #endif
536-
537- return errorString;
538- }
539-
540473PYBIND11_NOINLINE handle get_object_handle (const void *ptr, const detail::type_info *type) {
541474 auto &instances = get_internals ().registered_instances ;
542475 auto range = instances.equal_range (ptr);
0 commit comments