]> code.ossystems Code Review - openembedded-core.git/commitdiff
lib/oe: Fix collections ABCs DeprecationWarning in Python 3.7+
authorKhem Raj <raj.khem@gmail.com>
Wed, 8 Aug 2018 22:49:13 +0000 (15:49 -0700)
committerArmin Kuster <akuster808@gmail.com>
Tue, 9 Apr 2019 12:27:17 +0000 (17:57 +0530)
- Prefer collections.abc (new in Python 3.3) over collections for abstract base classes

- In Python 3.8, the abstract base classes in collections.abc will no longer be exposed in
  the regular collections module. This will help create a clearer distinction between
  the concrete classes and the abstract base classes."

- https://docs.python.org/3.7/whatsnew/3.7.html#deprecated

- see https://github.com/python/cpython/commit/c66f9f8d3909f588c251957d499599a1680e2320

Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Signed-off-by: Armin Kuster <akuster808@gmail.com>
meta/lib/oe/maketype.py

index f88981dd9023b8f734f5149202e545c0b219bcfa..c36e7b560465290f2620ea1b6552a89b90d2ec8e 100644 (file)
@@ -7,7 +7,12 @@ the arguments of the type's factory for details.
 
 import inspect
 import oe.types as types
-import collections
+try:
+    # Python 3.7+
+    from collections.abc import Callable
+except ImportError:
+    # Python < 3.7
+    from collections import Callable
 
 available_types = {}
 
@@ -96,7 +101,7 @@ for name in dir(types):
         continue
 
     obj = getattr(types, name)
-    if not isinstance(obj, collections.Callable):
+    if not isinstance(obj, Callable):
         continue
 
     register(name, obj)