[orca] modify collections module import for Python3.10 compatibility



commit cea2bebdbd9fd69561945d191d9d44beeef655cc
Author: Valentin Villenave <valentin villenave net>
Date:   Mon Nov 15 14:45:02 2021 +0100

    modify collections module import for Python3.10 compatibility

 src/orca/generator.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/src/orca/generator.py b/src/orca/generator.py
index 2058a436d..a7ff8f856 100644
--- a/src/orca/generator.py
+++ b/src/orca/generator.py
@@ -27,7 +27,6 @@ __copyright__ = "Copyright (c) 2009 Sun Microsystems Inc." \
                 "Copyright (c) 2015-2016 Igalia, S.L."
 __license__   = "LGPL"
 
-import collections
 import pyatspi
 import sys
 import time
@@ -41,6 +40,12 @@ from . import object_properties
 from . import settings
 from . import settings_manager
 
+# Python 3.10 compatibility:
+try:
+    import collections.abc as collections_abc
+except ImportError:
+    import collections as collections_abc
+
 def _formatExceptionInfo(maxTBlevel=5):
     cla, exc, trbk = sys.exc_info()
     excName = cla.__name__
@@ -78,7 +83,7 @@ class Generator:
         self._activeProgressBars = {}
         self._methodsDict = {}
         for method in \
-            [z for z in [getattr(self, y).__get__(self, self.__class__) for y in [x for x in dir(self) if 
x.startswith(METHOD_PREFIX)]] if isinstance(z, collections.abc.Callable)]:
+            [z for z in [getattr(self, y).__get__(self, self.__class__) for y in [x for x in dir(self) if 
x.startswith(METHOD_PREFIX)]] if isinstance(z, collections_abc.Callable)]:
             name = method.__name__[len(METHOD_PREFIX):]
             name = name[0].lower() + name[1:]
             self._methodsDict[name] = method


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]