validate: loggable: fix Callable import
authorMathieu Duponchelle <mathieu@centricular.com>
Fri, 7 Jan 2022 21:26:16 +0000 (22:26 +0100)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Tue, 11 Jan 2022 16:39:56 +0000 (16:39 +0000)
Since 3.3 importing Callable from collections is deprecated,
it should be imported from collections.abc .

Since 3.10 the alias has been removed altogether.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1504>

subprojects/gst-devtools/validate/launcher/loggable.py

index 404fd69..1dbad9f 100644 (file)
@@ -16,7 +16,6 @@
 # License along with this program; if not, write to the
 # Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
 # Boston, MA 02110-1301, USA.
-import collections
 import errno
 import fnmatch
 import os
@@ -27,6 +26,10 @@ import time
 import traceback
 import types
 
+try:
+    from collections.abc import Callable
+except ImportError:
+    from collections import Callable
 
 # environment variables controlling levels for each category
 _DEBUG = "*:1"
@@ -765,7 +768,7 @@ def addLogHandler(func):
         TypeError: When func is not a callable.
     """
 
-    if not isinstance(func, collections.Callable):
+    if not isinstance(func, Callable):
         raise TypeError("func must be callable")
 
     if func not in _log_handlers:
@@ -787,7 +790,7 @@ def addLimitedLogHandler(func):
     Raises:
         TypeError: When func is not a callable.
     """
-    if not isinstance(func, collections.Callable):
+    if not isinstance(func, Callable):
         raise TypeError("func must be callable")
 
     if func not in _log_handlers_limited: