[TxMt] Re: Problems with python bundle

Andrea Crotti kerny404 at gmail.com
Tue Dec 30 19:22:20 UTC 2008


It actually turns out that the problem is here

try:
    import _hashlib
    # use the wrapper of the C implementation
    new = __hash_new

    for opensslFuncName in filter(lambda n: n.startswith('openssl_'),
dir(_hashlib)):
        funcName = opensslFuncName[len('openssl_'):]
        try:
            # try them all, some may not work due to the OpenSSL
            # version not supporting that algorithm.
            f = getattr(_hashlib, opensslFuncName)
            f()
            # Use the C function directly (very fast)
            exec funcName + ' = f'
        except ValueError:
            try:
                # Use the builtin implementation directly (fast)
                exec funcName + ' = __get_builtin_constructor(funcName)'
            except ValueError:
                # this one has no builtin implementation, don't define it
                pass
    # clean up our locals
    del f
    del opensslFuncName
    del funcName

except ImportError:
    # We don't have the _hashlib OpenSSL module?
    # use the built in legacy interfaces via a wrapper function
    new = __py_new

    # lookup the C function to use directly for the named constructors
    md5 = __get_builtin_constructor('md5')
    sha1 = __get_builtin_constructor('sha1')
    sha224 = __get_builtin_constructor('sha224')
    sha256 = __get_builtin_constructor('sha256')
    sha384 = __get_builtin_constructor('sha384')
    sha512 = __get_builtin_constructor('sha512')


No wait a moment there's something strange here, I tried to add a print
sys.path to hashlib where it fails to import _hashlib (but from ipython
works without problems) and it says.
 in import hashlib File "hashlib.py", line 131, in print sys.path NameError:
name 'sys' is not defined

So for some reasons I can not import the damn module...
-- 
View this message in context: http://www.nabble.com/Problems-with-python-bundle-tp20577401p21221928.html
Sent from the textmate users mailing list archive at Nabble.com.




More information about the textmate mailing list