]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-118761: Always lazy import `warnings` in `threading` (#129428)
authorTaneli Hukkinen <3275109+hukkin@users.noreply.github.com>
Wed, 29 Jan 2025 17:24:37 +0000 (19:24 +0200)
committerGitHub <noreply@github.com>
Wed, 29 Jan 2025 17:24:37 +0000 (17:24 +0000)
Lib/threading.py
Misc/NEWS.d/next/Library/2025-01-29-11-14-20.gh-issue-118761.gMZwE1.rst [new file with mode: 0644]

index 78e591124278fc8bcc3752113fa05d349992e417..d7cc3ddc44516b6e4a170663a7da11e1a1c60397 100644 (file)
@@ -3,7 +3,6 @@
 import os as _os
 import sys as _sys
 import _thread
-import warnings
 
 from time import monotonic as _time
 from _weakrefset import WeakSet
@@ -133,6 +132,7 @@ def RLock(*args, **kwargs):
 
     """
     if args or kwargs:
+        import warnings
         warnings.warn(
             'Passing arguments to RLock is deprecated and will be removed in 3.15',
             DeprecationWarning,
diff --git a/Misc/NEWS.d/next/Library/2025-01-29-11-14-20.gh-issue-118761.gMZwE1.rst b/Misc/NEWS.d/next/Library/2025-01-29-11-14-20.gh-issue-118761.gMZwE1.rst
new file mode 100644 (file)
index 0000000..c247479
--- /dev/null
@@ -0,0 +1,2 @@
+Always lazy import ``warnings`` in :mod:`threading`. Patch by Taneli
+Hukkinen.