Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
7529ff29
Commit
7529ff29
authored
Oct 17, 2010
by
Hanno Schlichting
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Correct the default value of the __import__ level argument to be -1
parent
ad9c1bdb
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
6 deletions
+6
-6
doc/CHANGES.rst
doc/CHANGES.rst
+1
-1
src/AccessControl/ZopeGuards.py
src/AccessControl/ZopeGuards.py
+2
-2
src/AccessControl/tests/testModuleSecurity.py
src/AccessControl/tests/testModuleSecurity.py
+3
-3
No files found.
doc/CHANGES.rst
View file @
7529ff29
...
...
@@ -16,7 +16,7 @@ Features Added
++++++++++++++
- 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)
...
...
src/AccessControl/ZopeGuards.py
View file @
7529ff29
...
...
@@ -268,7 +268,7 @@ def guarded_zip(*seqs):
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 @@ def guarded_import(mname, globals=None, locals=None, fromlist=None,
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
)
...
...
src/AccessControl/tests/testModuleSecurity.py
View file @
7529ff29
...
...
@@ -32,13 +32,13 @@ class ModuleSecurityTests(unittest.TestCase):
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 @@ class ModuleSecurityTests(unittest.TestCase):
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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment