Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not print C errors by default #926

Merged
merged 2 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions bindings/python/dlite-entity-python.i
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,12 @@ def get_instance(
# Override default generated __init__() method
def __init__(self, *args, **kwargs):

# The swig-generated __new__() method is not a standard wrapper
# function and therefore bypass the standard error checking.
# Check manually that we are not in an error state.
_dlite.errcheck()
# Some versions of SWIG may generate a __new__() method that
# is not a standard wrapper function and will therefore bypass
# the standard error checking. Check manually that we are not
# in an error state.
if hasattr(self, "__new__"):
_dlite.errcheck()

if self is None:
raise _dlite.DLitePythonError(f"cannot create dlite.Instance")
Expand Down
10 changes: 7 additions & 3 deletions doc/user_guide/environment_variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,13 @@ DLite-specific environment variables
plugin search paths, while it only affects the plugin search paths on
Linux.

- **DLITE_PYDEBUG**: Traceback from errors happening Python plugins are normally
lost. But, if `DLITE_PYDEBUG` is defined, a Python error message will be
written to standard error.
- **DLITE_PYDEBUG**: If defined, it will turn on printing error
messages from C to standard error.

It will also enable tracebacks from exceptions happening in Python
plugins. Traceback from exceptions happening in Python plugins
are normally lost. But, with `DLITE_PYDEBUG` defined, the full error
message, including traceback, will be written to standard error.
jesper-friis marked this conversation as resolved.
Show resolved Hide resolved

- **DLITE_ATEXIT_FREE**: Free memory at exit. This might be useful to avoid
getting false positive when tracking down memory leaks with tools like valgrind.
Expand Down
2 changes: 1 addition & 1 deletion src/dlite-misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ void dlite_globals_set(DLiteGlobals *globals_handler)
/* Error handler for DLite. */
static void dlite_err_handler(const ErrRecord *record)
{
if (!dlite_err_ignored_get(record->eval))
if (!dlite_err_ignored_get(record->eval) && getenv("DLITE_PYDEBUG"))
err_default_handler(record);
}

Expand Down