Fix deprecation warning in Python 3.7 (#231)
authorScott Johnson <scottjohnsoninsf@gmail.com>
Sat, 22 Jun 2019 12:16:23 +0000 (05:16 -0700)
committerEli Bendersky <eliben@users.noreply.github.com>
Sat, 22 Jun 2019 12:16:23 +0000 (05:16 -0700)
$SITE_PYTHON/lib/python3.7/site-packages/elftools/construct/lib/container.py:5
 Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working

This change is compatible with Python 3.3 and up, when the ABCs were
moved to collections.abc. Backward compatibility is retained through
the try/except block.

elftools/construct/lib/container.py
elftools/construct/lib/py3compat.py

index 2f89b2dc400ade5389a1a08e48bfd3ff990f6942..5a580fac461b9e95fcebb7c5ad32db33a537081b 100644 (file)
@@ -2,8 +2,8 @@
 Various containers.
 """
 
-from collections import MutableMapping
 from pprint import pformat
+from .py3compat import MutableMapping
 
 def recursion_lock(retval, lock_name = "__recursion_lock__"):
     def decorator(func):
index 4a52c29305f91c9eee7eef71bc4eb44c21a1b1d2..1cbae81d6850b2f3b287859e90c982df7153c6ff 100644 (file)
@@ -6,6 +6,11 @@
 import sys
 PY3 = sys.version_info[0] == 3
 
+try:
+    from collections.abc import MutableMapping  # python >= 3.3
+except ImportError:
+    from collections import MutableMapping  # python < 3.3
+
 
 if PY3:
     import io