yunify / qingcloud-sdk-python

QingCloud SDK for Python
Apache License 2.0
54 stars 48 forks source link

perf: support python3.10+ version #100

Closed LeeEirc closed 1 year ago

LeeEirc commented 1 year ago

In Python 3.10+, the Iterable type has been moved to the collections.abc module. The past package, which is used to provide Python 3 compatibility for Python 2 code, might not have been updated to reflect this change.

if sys.version_info.major >= 3 and sys.version_info.minor >= 10:
    from collections.abc import Iterable
else:
    from collections import Iterable

I just monkey-patched the code.

Before the change, the error message might have looked something like this:

  1 """
      2 Pure-Python implementation of a Python 2-like str object for Python 3.
      3 """
----> 5 from collections import Iterable
      6 from numbers import Integral
      8 from past.utils import PY2, with_metaclass

ImportError: cannot import name 'Iterable' from 'collections'