Skip to content

Include Python traceback in libnomp error logs#291

Open
thilinarmtb wants to merge 1 commit into
mainfrom
add_python_exception_in_err
Open

Include Python traceback in libnomp error logs#291
thilinarmtb wants to merge 1 commit into
mainfrom
add_python_exception_in_err

Conversation

@thilinarmtb

@thilinarmtb thilinarmtb commented Jun 25, 2026

Copy link
Copy Markdown
Member

Python C-API failures in the nomp_py_* functions previously reported only a generic message
(e.g. "Calling realize_reduction() function failed."), discarding the actual Python exception. This
made debugging issues like the loopy reduction failure much harder than necessary.

Add nomp_py_err_str() to capture the active Python exception and format it (with traceback)
via traceback.format_exception, and route the shared check_py_call/check_py_str/check_error_
macros through a new nomp_py_log_() that appends the traceback to the nomp log. All nomp_py_*
functions gain the traceback at once since they share these macros.

Add test_python_traceback_in_log (nomp-api-100) asserting the traceback, including the
raised NameError, appears in the error string.

Python C-API failures in the nomp_py_* functions previously reported only
a generic message (e.g. "Calling realize_reduction() function failed."),
discarding the actual Python exception. This made debugging issues like
the loopy reduction failure much harder than necessary.

Add nomp_py_err_str() to capture the active Python exception and format it
(with traceback) via traceback.format_exception, and route the shared
check_py_call/check_py_str/check_error_ macros through a new nomp_py_log_()
that appends the traceback to the nomp log. All nomp_py_* functions gain
the traceback at once since they share these macros.

Add test_python_traceback_in_log (nomp-api-100) asserting the traceback,
including the raised NameError, appears in the error string.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@thilinarmtb thilinarmtb force-pushed the add_python_exception_in_err branch from 6401787 to 8158c2b Compare June 25, 2026 01:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant