rexec, threads, and ugly crashes

Jeremy Hylton jeremy at digicool.com
Fri Apr 20 11:28:42 EDT 2001


>>>>> "DF" == Danyel Fisher <danyelf at pupienus.ics.uci.edu> writes:

  DF> I'm in a multi-threaded application--a socket server--that is
  DF> executing arbitrary incoming code. Needless to say, I'm trying
  DF> to be careful. I want to restrict my visitors to calling things
  DF> from an API that I provide.

Is this a regular Python application, started by invoking the
interpreter with a script, or is it an application with an embedded
interpreter?

  DF> RExec is my tool.

I don't think the problem is related to rexec.

  DF> Sadly, an online search doesn't show much, except that it (used
  DF> to?)  happen with 1.5 modules used by 2.0 apps. I don't THINK my
  DF> rexec is an outdated version.

The error message means that a C extension module is being loaded
before Py_Initialize() has been called.  Py_Initialize() is called in
Py_Main() pretty much before it does anything else.

  DF> bash-2.04$ python -v mainmodule
  DF> Python 2.0 (#4, Apr 11 2001, 12:50:56) 
  DF> [GCC 2.96 20000731 (Red Hat Linux 7.0)] on linux2
  DF> ...
  DF> # /usr/local/lib/python2.0/rexec.pyc matches \
  DF> /usr/local/lib/python2.0/rexec.py
  DF> import rexec # precompiled from /usr/local/lib/python2.0/rexec.pyc
  DF> # /usr/local/lib/python2.0/ihooks.pyc matches \
  DF> /usr/local/lib/python2.0/ihooks.py
  DF> import ihooks # precompiled from /usr/local/lib/python2.0/ihooks.pyc
  DF> import imp # builtin
  DF> Fatal Python error: Interpreter not initialized (version mismatch?)
  DF> Aborted (core dumped)

What happens if you just type
bash-2.04$ python -v -c "import imp"

Jeremy





More information about the Python-list mailing list