[Zope-Checkins] SVN: Zope/branches/2.12/ Correct the default value of the __import__ level argument to be -1
Hanno Schlichting
hannosch at hannosch.eu
Sun Oct 17 07:31:09 EDT 2010
Log message for revision 117588:
Correct the default value of the __import__ level argument to be -1
Changed:
U Zope/branches/2.12/doc/CHANGES.rst
U Zope/branches/2.12/src/AccessControl/ZopeGuards.py
U Zope/branches/2.12/src/AccessControl/tests/testModuleSecurity.py
-=-
Modified: Zope/branches/2.12/doc/CHANGES.rst
===================================================================
--- Zope/branches/2.12/doc/CHANGES.rst 2010-10-16 07:34:29 UTC (rev 117587)
+++ Zope/branches/2.12/doc/CHANGES.rst 2010-10-17 11:31:08 UTC (rev 117588)
@@ -16,7 +16,7 @@
++++++++++++++
- LP #659968: Added support for level argument to the ``__import__`` function
- as introduced in Python 2.5. Currently only level=0 is supported.
+ as introduced in Python 2.5. Currently only level=-1 is supported.
2.12.12 (2010-10-02)
Modified: Zope/branches/2.12/src/AccessControl/ZopeGuards.py
===================================================================
--- Zope/branches/2.12/src/AccessControl/ZopeGuards.py 2010-10-16 07:34:29 UTC (rev 117587)
+++ Zope/branches/2.12/src/AccessControl/ZopeGuards.py 2010-10-17 11:31:08 UTC (rev 117588)
@@ -268,7 +268,7 @@
safe_builtins['zip'] = guarded_zip
def guarded_import(mname, globals=None, locals=None, fromlist=None,
- level=0):
+ level=-1):
if fromlist is None:
fromlist = ()
if '*' in fromlist:
@@ -278,7 +278,7 @@
if locals is None:
locals = {}
# Refs https://bugs.launchpad.net/zope2/+bug/659968
- if level != 0:
+ if level != -1:
raise Unauthorized("Using import with a level specification isn't "
"supported by AccessControl: %s" % mname)
Modified: Zope/branches/2.12/src/AccessControl/tests/testModuleSecurity.py
===================================================================
--- Zope/branches/2.12/src/AccessControl/tests/testModuleSecurity.py 2010-10-16 07:34:29 UTC (rev 117587)
+++ Zope/branches/2.12/src/AccessControl/tests/testModuleSecurity.py 2010-10-17 11:31:08 UTC (rev 117588)
@@ -32,13 +32,13 @@
if module in sys.modules:
del sys.modules[module]
- def assertUnauth(self, module, fromlist, level=0):
+ def assertUnauth(self, module, fromlist, level=-1):
from zExceptions import Unauthorized
from AccessControl.ZopeGuards import guarded_import
self.assertRaises(Unauthorized, guarded_import, module,
fromlist=fromlist, level=level)
- def assertAuth(self, module, fromlist, level=0):
+ def assertAuth(self, module, fromlist, level=-1):
from AccessControl.ZopeGuards import guarded_import
guarded_import(module, fromlist=fromlist, level=level)
@@ -77,7 +77,7 @@
self.failUnless('AccessControl.tests.nonesuch' in MS)
def test_level_zero(self):
- self.assertAuth('AccessControl.tests.public_module', (), level=0)
+ self.assertAuth('AccessControl.tests.public_module', (), level=-1)
def test_level_nonzero(self):
self.assertUnauth('AccessControl.tests.public_module', (), level=1)
More information about the Zope-Checkins
mailing list