Skip to content

Commit 87b4e12

Browse files
committed
Make collections import more robust for python 3
1 parent cd62d68 commit 87b4e12

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

pygccxml/declarations/scopedef.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
"""Defines :class:`scopedef_t` class"""
77

88
import timeit
9-
import collections
9+
try:
10+
from collections.abc import Callable
11+
except ImportError:
12+
from collections import Callable
1013

1114
from . import algorithm
1215
from . import templates
@@ -312,7 +315,7 @@ def init_optimizer(self):
312315

313316
@staticmethod
314317
def _build_operator_function(name, function):
315-
if isinstance(name, collections.Callable):
318+
if isinstance(name, Callable):
316319
return name
317320

318321
return function
@@ -324,7 +327,7 @@ def add_operator(sym):
324327
if 'new' in sym or 'delete' in sym:
325328
return 'operator ' + sym
326329
return 'operator' + sym
327-
if isinstance(name, collections.Callable) and None is function:
330+
if isinstance(name, Callable) and None is function:
328331
name = None
329332
if name:
330333
if 'operator' not in name:
@@ -347,7 +350,7 @@ def _on_rename(self):
347350
@staticmethod
348351
def __normalize_args(**keywds):
349352
"""implementation details"""
350-
if isinstance(keywds['name'], collections.Callable) and \
353+
if isinstance(keywds['name'], Callable) and \
351354
None is keywds['function']:
352355
keywds['function'] = keywds['name']
353356
keywds['name'] = None

0 commit comments

Comments
 (0)