]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Add stacklevel to deprecation warnings 3159/head
authorMin RK <benjaminrk@gmail.com>
Fri, 17 Jun 2022 09:22:53 +0000 (11:22 +0200)
committerMin RK <benjaminrk@gmail.com>
Fri, 17 Jun 2022 09:22:53 +0000 (11:22 +0200)
so warnings are associated with the line where the deprecated methods are called
rather than the line where the warning itself is

tornado/ioloop.py
tornado/platform/asyncio.py

index 9bb977ba19b94f9c1b635228ae17b1f250c6486a..b907106ef47d0bec27f230f82512dbac91c283d0 100644 (file)
@@ -312,7 +312,11 @@ class IOLoop(Configurable):
            This method also clears the current `asyncio` event loop.
         .. deprecated:: 6.2
         """
-        warnings.warn("clear_current is deprecated", DeprecationWarning)
+        warnings.warn(
+            "clear_current is deprecated",
+            DeprecationWarning,
+            stacklevel=2,
+        )
         IOLoop._clear_current()
 
     @staticmethod
index 58d31ddd8158e7cdcbb244ccc7cc48073ae03ca3..eed45d068154b929b51d31f377375e2c83f0b143 100644 (file)
@@ -341,6 +341,7 @@ class AsyncIOLoop(BaseAsyncIOLoop):
         warnings.warn(
             "make_current is deprecated; start the event loop first",
             DeprecationWarning,
+            stacklevel=2,
         )
         if not self.is_current:
             try:
@@ -425,6 +426,7 @@ class AnyThreadEventLoopPolicy(_BasePolicy):  # type: ignore
             "AnyThreadEventLoopPolicy is deprecated, use asyncio.run "
             "or asyncio.new_event_loop instead",
             DeprecationWarning,
+            stacklevel=2,
         )
 
     def get_event_loop(self) -> asyncio.AbstractEventLoop: