It seems that, in Debian jessie and later, the main Python binary now
exports `md5_init' and friends. Unfortunately, this overrides
Catacomb's existing `md5_init' with a rather different version, and the
result is a segfault (on i386) or wrong answers (on amd64).
So, as an unpleasant bodge (while this broken thing makes its way
through Debian, see bug #868366), try to force the `RTLD_DEEPBIND' flag
when loading the module. This is unfortunate, because Python doesn't
actually advertise this flag, at least in my version.
(cherry picked from commit
a3ae4a9f590ef84d8e6eac0bc94873a9fd943073)
from binascii import hexlify as _hexify, unhexlify as _unhexify
from contextlib import contextmanager as _ctxmgr
from binascii import hexlify as _hexify, unhexlify as _unhexify
from contextlib import contextmanager as _ctxmgr
+try: import DLFCN as _dlfcn
+except ImportError: _dlfcn = None
+import os as _os
from struct import pack as _pack
import sys as _sys
import types as _types
from struct import pack as _pack
import sys as _sys
import types as _types
###--------------------------------------------------------------------------
### Import the main C extension module.
###--------------------------------------------------------------------------
### Import the main C extension module.
+try:
+ _dlflags = _odlflags = _sys.getdlopenflags()
+except AttributeError:
+ _dlflags = _odlflags = -1
+
+## Set the `deep binding' flag. Python has its own different MD5
+## implementation, and some distributions export `md5_init' and friends so
+## they override our versions, which doesn't end well. Figure out how to
+## turn this flag on so we don't have the problem.
+if _dlflags >= 0:
+ try: _dlflags |= _dlfcn.RTLD_DEEPBIND
+ except AttributeError:
+ try: _dlflags |= _os.RTLD_DEEPBIND
+ except AttributeError:
+ if _os.uname()[0] == 'Linux': _dlflags |= 8 # magic knowledge
+ else: pass # can't do this.
+ _sys.setdlopenflags(_dlflags)
+
+if _odlflags >= 0:
+ _sys.setdlopenflags(_odlflags)
+
+del _dlflags, _odlflags
+
###--------------------------------------------------------------------------
### Basic stuff.
###--------------------------------------------------------------------------
### Basic stuff.