Просмотр исходного кода

ctypes: fix Callable for Python 3.10 (#1673)

Callable is now part of collections.abc: replacing `collections.Callable` with `collections.abc.Callable`

Fixes #1671

Co-authored-by: @petrasovaa
Markus Neteler 3 лет назад
Родитель
Сommit
4c4ddbdcdb
1 измененных файлов с 2 добавлено и 2 удалено
  1. 2 2
      lib/python/ctypes/ctypesgencore/parser/lex.py

+ 2 - 2
lib/python/ctypes/ctypesgencore/parser/lex.py

@@ -348,7 +348,7 @@ class Lexer:
                     break
                     break
 
 
                 # if func not callable, it means it's an ignored token
                 # if func not callable, it means it's an ignored token
-                if not isinstance(func, collections.Callable):
+                if not isinstance(func, collections.abc.Callable):
                     break
                     break
 
 
                 # If token is processed by a function, call it
                 # If token is processed by a function, call it
@@ -720,7 +720,7 @@ def lex(module=None, object=None, debug=0, optimize=0,
         states, tokname = _statetoken(f, stateinfo)
         states, tokname = _statetoken(f, stateinfo)
         toknames[f] = tokname
         toknames[f] = tokname
 
 
-        if isinstance(t, collections.Callable):
+        if isinstance(t, collections.abc.Callable):
             for s in states:
             for s in states:
                 funcsym[s].append((f, t))
                 funcsym[s].append((f, t))
         elif (isinstance(t, bytes) or isinstance(t, str)):
         elif (isinstance(t, bytes) or isinstance(t, str)):