Skip to content

Commit

Permalink
[bugfix] Set stacklevel=2 for dgl_warning (dmlc#3816)
Browse files Browse the repository at this point in the history
Co-authored-by: Jinjing Zhou <[email protected]>
Co-authored-by: Minjie Wang <[email protected]>
  • Loading branch information
3 people authored Mar 25, 2022
1 parent 7d41608 commit f73c7a6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions python/dgl/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ def dgl_warning_format(message, category, filename, lineno, line=None):
else:
return _default_formatwarning(message, category, filename, lineno, line=None)

def dgl_warning(message, category=DGLWarning, stacklevel=1):
def dgl_warning(message, category=DGLWarning, stacklevel=2):
"""DGL warning wrapper that defaults to ``DGLWarning`` instead of ``UserWarning`` category."""
return warnings.warn(message, category=category, stacklevel=1)
return warnings.warn(message, category=category, stacklevel=stacklevel)

warnings.formatwarning = dgl_warning_format

Expand Down

0 comments on commit f73c7a6

Please sign in to comment.