Skip to content

Commit 78b9345

Browse files
author
Vasileios Karakasis
committed
Fix crash of user_deprecation_warning() without a runtime
1 parent c3f47fd commit 78b9345

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

reframe/core/warnings.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
import contextlib
12
import inspect
23
import warnings
34

5+
from reframe.core.exceptions import ReframeFatalError
6+
47

58
class ReframeDeprecationWarning(DeprecationWarning):
69
'''Warning raised for deprecated features of the framework.'''
@@ -28,8 +31,12 @@ def _format_warning(message, category, filename, lineno, line=None):
2831
line = '<no line information>'
2932

3033
message = f'{filename}:{lineno}: WARNING: {message}\n{line}\n'
31-
if rt.runtime().get_option('general/0/colorize'):
32-
message = color.colorize(message, color.YELLOW)
34+
35+
# Ignore coloring if runtime has not been initialized; this can happen
36+
# when generating the documentation of deprecated APIs
37+
with contextlib.suppress(ReframeFatalError):
38+
if rt.runtime().get_option('general/0/colorize'):
39+
message = color.colorize(message, color.YELLOW)
3340

3441
return message
3542

0 commit comments

Comments
 (0)