Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Python 3.10.x not working #49

Open
Cellebyte opened this issue Feb 8, 2022 · 3 comments
Open

[Bug] Python 3.10.x not working #49

Cellebyte opened this issue Feb 8, 2022 · 3 comments

Comments

@Cellebyte
Copy link

Cellebyte commented Feb 8, 2022

As of the new python release 3.10.x some modules which are used as a dependency are not working for pytos.
It would be great if the dependencies can be updated to work also with python 3.10.

https://bugs.python.org/issue25988

$ python -m tufin.pytos.module
Traceback (most recent call last):
    from pytos.secureapp.helpers import Secure_App_Helper
  File "/home/cellebyte/git/tools/cli/infoblox-sync/.venv/lib/python3.10/site-packages/pytos/secureapp/helpers.py", line 16, in <module>
    from pytos.securechange.helpers import Secure_Change_Helper
  File "/home/cellebyte/git/tools/cli/infoblox-sync/.venv/lib/python3.10/site-packages/pytos/securechange/helpers.py", line 19, in <module>
    from pytos.common.helpers import Secure_API_Helper
  File "/home/cellebyte/git/tools/cli/infoblox-sync/.venv/lib/python3.10/site-packages/pytos/common/helpers.py", line 7, in <module>
    from pytos.common import rest_requests
  File "/home/cellebyte/git/tools/cli/infoblox-sync/.venv/lib/python3.10/site-packages/pytos/common/rest_requests.py", line 16, in <module>
    import requests_toolbelt
  File "/home/cellebyte/git/tools/cli/infoblox-sync/.venv/lib/python3.10/site-packages/requests_toolbelt/__init__.py", line 12, in <module>
    from .adapters import SSLAdapter, SourceAddressAdapter
  File "/home/cellebyte/git/tools/cli/infoblox-sync/.venv/lib/python3.10/site-packages/requests_toolbelt/adapters/__init__.py", line 12, in <module>
    from .ssl import SSLAdapter
  File "/home/cellebyte/git/tools/cli/infoblox-sync/.venv/lib/python3.10/site-packages/requests_toolbelt/adapters/ssl.py", line 16, in <module>
    from .._compat import poolmanager
  File "/home/cellebyte/git/tools/cli/infoblox-sync/.venv/lib/python3.10/site-packages/requests_toolbelt/_compat.py", line 11, in <module>
    from collections import Mapping, MutableMapping
ImportError: cannot import name 'Mapping' from 'collections' (/usr/lib/python3.10/collections/__init__.py)
@marioland
Copy link
Contributor

Workaround in pytos\common\rest_requests.py
insert
from collections import abc as collections
instead of the top line

@Cellebyte
Copy link
Author

@marioland the workaround only works when you manually patch the library.
Would be better to fix it upstream.

@Cellebyte
Copy link
Author

for the people waiting for #52 I have a working hotfix.

# <project_name>/_hotfix.py
from collections.abc import MutableMapping, Mapping
from collections import (
    ChainMap,
    namedtuple,
    OrderedDict,
    deque,
    defaultdict,
    Counter,
    UserDict,
    UserList,
    UserString,
)
from collections import abc

__all__ = [
    "ChainMap",
    "MutableMapping",
    "Mapping",
    "namedtuple",
    "OrderedDict",
    "abc",
    "deque",
    "defaultdict",
    "Counter",
    "UserDict",
    "UserList",
    "UserString",
]
# <project_name>.__init__.py
import sys
import <project_name>._hotfix as collections

sys.modules["collections"] = collections

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants