summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Reiter <reiter.christoph@gmail.com>2018-08-15 16:59:50 +0200
committerChristoph Reiter <reiter.christoph@gmail.com>2018-08-15 22:32:40 +0200
commite3d412385703bc240e72ec13ea14e9a317bceb93 (patch)
tree1612e30441a7f62673626093e78f70fc6eb1cdd4
parent40f93af08c993325279fbb87cdd0a3be95c67a8e (diff)
downloadpygobject-e3d412385703bc240e72ec13ea14e9a317bceb93.tar.gz
Access abc classes through the abc module with Python 3
It will stop to work with Python 3.8
-rw-r--r--gi/overrides/Gtk.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/gi/overrides/Gtk.py b/gi/overrides/Gtk.py
index 612c07da..05da18aa 100644
--- a/gi/overrides/Gtk.py
+++ b/gi/overrides/Gtk.py
@@ -19,10 +19,14 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
# USA
-import collections
import sys
import warnings
+if sys.version_info[0] == 2:
+ import collections as abc
+else:
+ from collections import abc
+
from gi.repository import GObject
from .._ossighelper import wakeup_on_signal, register_sigint_fallback
from .._gtktemplate import Template
@@ -77,7 +81,7 @@ __all__.append('_construct_target_list')
def _extract_handler_and_args(obj_or_map, handler_name):
handler = None
- if isinstance(obj_or_map, collections.Mapping):
+ if isinstance(obj_or_map, abc.Mapping):
handler = obj_or_map.get(handler_name, None)
else:
handler = getattr(obj_or_map, handler_name, None)
@@ -86,7 +90,7 @@ def _extract_handler_and_args(obj_or_map, handler_name):
raise AttributeError('Handler %s not found' % handler_name)
args = ()
- if isinstance(handler, collections.Sequence):
+ if isinstance(handler, abc.Sequence):
if len(handler) == 0:
raise TypeError("Handler %s tuple can not be empty" % handler)
args = handler[1:]