[Zope-dev] Problem with Zope 2.6.0 and ZShell
Guido van Rossum
guido@python.org
Tue, 19 Nov 2002 14:13:19 -0500
> On Tue, Nov 19, 2002 at 01:54:56PM -0500, Guido van Rossum wrote:
> >
> > > Since I don't actually use Zope 2.6, does anyone have an idea on
> > > where the problem may come from ?
> >
> > You're using restricted mode (the rexec module) and this apparently
> > doesn't provide sys.hexversion. This is a shallow bug; it's already
> > fixed in Python 2.3 (CVS).
> > ...
> > Probably those versions of Python didn't have the test for
> > sys.hexversion; it's testing whether this is Python 2.2 or higher.
> >
> > A workaround would be to set sys.hexversion to 0x02020000 (or to 0 if
> > you're not sure which Python version you're using) before importing
> > sre for the first time.
>
> Thanks for your answer.
>
> Unfortunately I never import sre.
>
> I import re, then rexec in the main program,
> then in the restricted code I add the
> os and os.path modules, and the resticted code
> then import the glob modules and calls its glob
> method.
>
> So should I set sys.hexversion *before* my re and rexec
> imports in the main program, or add the sys module and
> a fake hexversion value in the restricted code ?
In the restricted code, right at the start. Restricted code loads its
own copy of each module it uses. The glob module uses re, which uses
sre.
--Guido van Rossum (home page: http://www.python.org/~guido/)