Fails with no trivial structure
nathanielobrown opened this issue · 2 comments
I am trying to use this example for some production code and can not seem to get it to work in anything but simple examples. Instead I get an endless stream of errors like:
<type 'exceptions.TypeError'>
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
TypeError: must be string or None, not list
This ends after a period of time in python crashing or it will just stop on one of the TypeErrors. I suspect it has to do with an improper handling of some package structure or import method.
I know this is a little vague, but do you have any intuition about what might be going wrong that might point me in the right direction? Any loose ends in CryptImpHook_load_module
? I am on Windows 7 with python 2.7.10 compiling with Microsoft Visual C++ 2008 for Python.
Hi @nbrown14
This is pretty old code, but I can try to reproduce and report back.
What Python code is giving you this error? Is this in the encryption part or the decryption part?
Really it is just the import part. I tried changing things so that no encryption was performed and only the file extension was changed and still found the same behavior. I also had to make a few tweaks to get things to work on windows.
I have determined that the issue has to do with importing regular installed packages. It appears that just adding the import hook causes some problems. My findings are:
-
Standard library modules import fine. Example:
import sys from CryptImpHook import CryptImpHook sys.meta_path.append(CryptImpHook()) import re
-
Standard library packages seem to work after a few
TyperErrors
. Example threw 8TypeErrors
but then workedimport sys from CryptImpHook import CryptImpHook sys.meta_path.append(CryptImpHook()) import json
-
Site-packages modules throw several
TypeErrors
but then import properly. Example threw 15TypeErrors
and then workedimport sys from CryptImpHook import CryptImpHook sys.meta_path.append(CryptImpHook()) import xmltodict
-
Site-packages packages throw
TypeErrors
until python crashes in some cases. Importing beautifulsoup (import bs4
) fails,import requests
succeeds after a large number ofTypeErrors
import sys from CryptImpHook import CryptImpHook sys.meta_path.append(CryptImpHook()) import xmltodict import sys from CryptImpHook import CryptImpHook sys.meta_path.append(CryptImpHook()) import xmltodict
-
Importing modules ending in pye works fine, packages containing pye files do not (I am not too concerned about this)
-
I reproduced this behavior on Ubuntu 14.04.2 running Python 2.7.10 and using an unmodified version of your code.
I really appreciate that you responded to my issue. My C is weak and the Python C API scares me, but I might be able to figure this out with a few pointers (pun intended).