Bladeren bron

adjust warning stack level

wangweimin 3 jaren geleden
bovenliggende
commit
7c284ce07a
2 gewijzigde bestanden met toevoegingen van 4 en 1 verwijderingen
  1. 3 1
      pywebio/output.py
  2. 1 0
      pywebio/platform/utils.py

+ 3 - 1
pywebio/output.py

@@ -1140,8 +1140,9 @@ def put_scrollable(content=[], height=400, keep_bottom=False, border=True,
 
     if 'max_height' in kwargs:
         import warnings
+        # use stacklevel=2 to make the warning refer to the put_scrollable() call
         warnings.warn("`max_height` parameter is deprecated in `put_scrollable()`, use `height` instead.",
-                      DeprecationWarning, stacklevel=3)
+                      DeprecationWarning, stacklevel=2)
         height = kwargs['max_height']  # Backward compatible
 
     try:
@@ -1460,6 +1461,7 @@ def output(*contents):
     """
 
     import warnings
+    # use stacklevel=2 to make the warning refer to the output() call
     warnings.warn("`pywebio.output.output()` is deprecated since v1.5 and will remove in the future version, "
                   "use `pywebio.output.put_scope()` instead", DeprecationWarning, stacklevel=2)
 

+ 1 - 0
pywebio/platform/utils.py

@@ -74,6 +74,7 @@ def cdn_validation(cdn, level='warn', stacklevel=3):
 
     :param bool/str cdn: cdn parameter
     :param level: warn or error
+    :param stacklevel: stacklevel=3 to makes the warning refer to cdn_validation() caller’s caller
     """
     assert level in ('warn', 'error')