Skip to content

Commit

Permalink
Improve the warning message for old_style error capturing deprecation.
Browse files Browse the repository at this point in the history
  • Loading branch information
sklam committed Aug 22, 2023
1 parent da49bf3 commit 8d04ce8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
14 changes: 9 additions & 5 deletions numba/core/utils.py
Expand Up @@ -192,17 +192,21 @@ def shutting_down(globals=globals):
atexit.register(_at_shutdown)


_old_style_deprecation_msg = (
"Code using Numba extension API maybe depending on 'old_style' error-capturing,"
" which is deprecated and will be replaced by 'new_style' in a future release."
" See details at https://numba.readthedocs.io/en/latest/reference/deprecation.html#deprecation-of-old-style-numba-captured-errors" # noqa: E501
)


def _warn_old_style():
from numba.core import errors # to prevent circular import

exccls, _, _ = sys.exc_info()
# Warn only if the active exception is not a NumbaError
if exccls is not None and not issubclass(exccls, errors.NumbaError):
warnings.warn(
"The 'old_style' error capturing is deprecated "
"and will be replaced by `new_style` in a future release.",
errors.NumbaPendingDeprecationWarning,
)
warnings.warn(_old_style_deprecation_msg,
errors.NumbaPendingDeprecationWarning)


def use_new_style_errors():
Expand Down
7 changes: 5 additions & 2 deletions numba/tests/test_errorhandling.py
Expand Up @@ -493,8 +493,11 @@ def ol_bar(x):
def foo(x):
bar(x)

self.assertIn("The 'old_style' error capturing is deprecated",
str(warns.warnings[0].message))
self.assertIn(
"Code using Numba extension API maybe depending on 'old_style' "
"error-capturing",
str(warns.warnings[0].message),
)

@TestCase.run_test_in_subprocess(
envvars={"NUMBA_CAPTURED_ERRORS": "old_style"},
Expand Down

2 comments on commit 8d04ce8

@seanlaw
Copy link
Contributor

@seanlaw seanlaw commented on 8d04ce8 Aug 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sklam Currently, the warning is being output in many of my unit tests when executing them with Numba 0.58.0rc1 and llvmlite 0.41.0rc1. It's not clear whether these warnings are temporary OR if something in my code is triggering these warnings? Will I need to filter these warnings moving forward or is there a way for me to change my code so that these warnings are "fixed"?

@sklam
Copy link
Member Author

@sklam sklam commented on 8d04ce8 Aug 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@seanlaw, I will check if the warning is showing excessively because of a logic error being fixed in #9152.

Please sign in to comment.