From ec3ce7aef387878abd10a3991e4c3610c98cc70d Mon Sep 17 00:00:00 2001 From: Erik Jansson Agnvall Date: Fri, 16 Aug 2019 14:09:38 +0200 Subject: [PATCH] Add conditional import of MutableMapping Importing the abstract base classes directly from the collections module is deprecated in Python 3.7. They have been moved to collections.abc and the deprecated way will stop working in Python 3.8. See: https://docs.python.org/3/library/collections.html --- symengine/lib/symengine_wrapper.pyx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/symengine/lib/symengine_wrapper.pyx b/symengine/lib/symengine_wrapper.pyx index 290b56647..0c08ad903 100644 --- a/symengine/lib/symengine_wrapper.pyx +++ b/symengine/lib/symengine_wrapper.pyx @@ -19,6 +19,12 @@ import collections import warnings from symengine.compatibility import is_sequence import os +import sys + +if sys.version_info[0] == 2: + from collections import MutableMapping +else: + from collections.abc import MutableMapping try: import numpy as np @@ -720,7 +726,7 @@ cdef class _DictBasic(object): return d -class DictBasic(_DictBasic, collections.MutableMapping): +class DictBasic(_DictBasic, MutableMapping): def __str__(self): return "{" + ", ".join(["%s: %s" % (str(key), str(value)) for key, value in self.items()]) + "}"