[Zope-Checkins] CVS: Zope/lib/python/RestrictedPython - SelectCompiler.py:1.2.2.2
Brian Lloyd
brian@digicool.com
Sat, 22 Dec 2001 11:38:29 -0500
Update of /cvs-repository/Zope/lib/python/RestrictedPython
In directory cvs.zope.org:/tmp/cvs-serv4671
Modified Files:
Tag: Zope-2_5-branch
SelectCompiler.py
Log Message:
Changed to select compiler package based on version_info, as there
are situations where checking for a local compiler package will fail
to do the right thing.
=== Zope/lib/python/RestrictedPython/SelectCompiler.py 1.2.2.1 => 1.2.2.2 ===
'''
-try:
- import compiler # Should only be found if Python >= 2.2.
-except ImportError:
+import sys
+
+if sys.version_info[1] < 2:
# Use the compiler_2_1 package.
from compiler_2_1 import ast
from compiler_2_1.transformer import parse
@@ -30,6 +30,7 @@
compile_restricted_eval
else:
# Use the compiler from the standard library.
+ import compiler
from compiler import ast
from compiler.transformer import parse
from compiler.consts import OP_ASSIGN, OP_DELETE, OP_APPLY