oletools icon indicating copy to clipboard operation
oletools copied to clipboard

colorclass dependency causes incompatibility with CPython 3.10

Open michaelweiser opened this issue 2 years ago • 3 comments

oletools.olevba will fail on import in the colorclass dependency in CPython 3.10:

$ oletools/bin/python3.10 -c "import oletools.olevba"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/oletools/lib/python3.10/site-packages/oletools/olevba.py", line 307, in <module>
    import colorclass
  File "/oletools/lib/python3.10/site-packages/colorclass/__init__.py", line 11, in <module>
    from colorclass.codes import list_tags  # noqa
  File "/oletools/lib/python3.10/site-packages/colorclass/codes.py", line 4, in <module>
    from collections import Mapping
ImportError: cannot import name 'Mapping' from 'collections' (/usr/lib/python3.10/collections/__init__.py)

There's a fix proposed at the upstream repository: Robpol86/colorclass#27. It does not look like it's going to be adopted any time soon.

Would you consider making the dependency optional or otherwise work around the problem?

Additional info:

$ python3.10 -V
Python 3.10.0b4
$ python3.10 -mvenv oletools
$ oletools/bin/pip install oletools
Collecting oletools
  Using cached oletools-0.60-py2.py3-none-any.whl (968 kB)
Collecting easygui
  Using cached easygui-0.98.2-py2.py3-none-any.whl (92 kB)
Collecting pcodedmp>=1.2.5
  Using cached pcodedmp-1.2.6-py2.py3-none-any.whl (30 kB)
Collecting msoffcrypto-tool
  Using cached msoffcrypto_tool-4.12.0-py2.py3-none-any.whl (33 kB)
Collecting olefile>=0.46
  Using cached olefile-0.46.zip (112 kB)
Collecting colorclass
  Using cached colorclass-2.2.0.tar.gz (17 kB)
Collecting pyparsing<3,>=2.1.0
  Using cached pyparsing-2.4.7-py2.py3-none-any.whl (67 kB)
Collecting cryptography>=2.3
  Using cached cryptography-3.4.7-cp36-abi3-manylinux2014_x86_64.whl (3.2 MB)
Collecting cffi>=1.12
  Using cached cffi-1.14.6.tar.gz (475 kB)
Collecting pycparser
  Using cached pycparser-2.20-py2.py3-none-any.whl (112 kB)
Using legacy 'setup.py install' for olefile, since package 'wheel' is not installed.
Using legacy 'setup.py install' for colorclass, since package 'wheel' is not installed.
Using legacy 'setup.py install' for cffi, since package 'wheel' is not installed.
Installing collected packages: pycparser, cffi, olefile, cryptography, pyparsing, pcodedmp, msoffcrypto-tool, easygui, colorclass, oletools
    Running setup.py install for cffi ... done
    Running setup.py install for olefile ... done
    Running setup.py install for colorclass ... done
Successfully installed cffi-1.14.6 colorclass-2.2.0 cryptography-3.4.7 easygui-0.98.2 msoffcrypto-tool-4.12.0 olefile-0.46 oletools-0.60 pcodedmp-1.2.6 pycparser-2.20 pyparsing-2.4.7
WARNING: You are using pip version 21.1.3; however, version 21.2.2 is available.
You should consider upgrading via the '/oletools/bin/python3.10 -m pip install --upgrade pip' command.

michaelweiser avatar Aug 05 '21 07:08 michaelweiser

There's been a new release 2.2.2 of colorclass with includes the fix. The problem is gone in my tests. So I believe this issue can be closed.

michaelweiser avatar Jan 07 '22 09:01 michaelweiser

I confirm this works fine with the new fork of colorclass (https://github.com/matthewdeanmartin/colorclass) on Python 3.10. pip installs colorclass 2.2.2 when upgrading (pip install -U colorclass).

decalage2 avatar Aug 16 '22 12:08 decalage2

Actually I should update the dependency requirements in setup.py to force the upgrade to colorclass>=2.2.2.

decalage2 avatar Aug 17 '22 08:08 decalage2