[Python-Dev] Unexpected rexec behavior due to _sre

Guido van Rossum guido@beopen.com
Tue, 12 Sep 2000 16:48:47 -0500


> Python 1.5.2 (#3, Feb 11 2000, 15:30:14)  [GCC 2.7.2.3.f.1] on linux2
> Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
> >>> import rexec
> >>> r = rexec.RExec()
> >>> r.r_exec("import re")
> >>> 
> 
> Python 2.0b1 (#2, Sep  8 2000, 12:10:17) 
> [GCC 2.95.2 19991024 (release)] on linux2
> Type "copyright", "credits" or "license" for more information.
> >>> import rexec
> >>> r=rexec.RExec()
> >>> r.r_exec("import re")
> 
> Traceback (most recent call last):
[...]
> ImportError: No module named _sre
> 
> Of course I can work around this by doing:
> 
> >>> r.ok_builtin_modules += '_sre',
> >>> r.r_exec("import re")          
> 
> But I really shouldn't have to do this, right?  _sre is supposed to be
> a low-level implementation detail.  I think I should still be able to 
> "import re" in an restricted environment without having to be aware of
> _sre.

The rexec.py module needs to be fixed.  Should be simple enough.
There may be other modules that it should allow too!

--Guido van Rossum (home page: http://www.pythonlabs.com/~guido/)