Skip to content

Commit

Permalink
worked on @icemac review requests
Browse files Browse the repository at this point in the history
  • Loading branch information
loechel committed May 24, 2017
1 parent 378f276 commit aff8e7a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
6 changes: 3 additions & 3 deletions README.rst
Expand Up @@ -26,11 +26,11 @@ This would not harm any system.
... return 'Hello World!'
... """
>>>
>>> locals = {}
>>> loc = {}
>>> byte_code = compile_restricted(source_code, '<inline>', 'exec')
>>> exec(byte_code, safe_builtins, locals)
>>> exec(byte_code, safe_builtins, loc)
>>>
>>> locals['example']()
>>> loc['example']()
'Hello World!'

Problematic code example
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Expand Up @@ -27,9 +27,9 @@ def read(*rnames):
version='4.0a2.dev0',
url='http://pypi.python.org/pypi/RestrictedPython',
license='ZPL 2.1',
description='RestrictedPython is a defined subset of the Python language'
' which allows to provide a program input into a trusted'
' environment.',
description='RestrictedPython is a defined subset of the Python '
'language which allows to provide a program input into '
'a trusted environment.',
long_description=(read('README.rst') + '\n' +
read('docs', 'CHANGES.rst')),
classifiers=[
Expand Down
15 changes: 9 additions & 6 deletions tests/test_imports.py
Expand Up @@ -2,6 +2,7 @@
Tests about imports
"""

from RestrictedPython import safe_builtins
from tests import c_exec
from tests import e_exec

Expand All @@ -21,9 +22,11 @@ def test_os_import(c_exec, e_exec):
"""Test that import should not work out of the box.
TODO: Why does this work.
"""
result = c_exec(OS_IMPORT_EXAMPLE)
assert result.code is not None
assert result.errors == ()

# with pytest.raises(NameError):
# e_exec(OS_IMPORT_EXAMPLE)
result = c_exec(OS_IMPORT_EXAMPLE, safe_builtins)
# TODO: there is a tests/__init__.py problem, as it seems to pass the
# safe_builtins into the compile function instead of the source.
assert result.code is None
# assert result.errors == ()

with pytest.raises(NameError):
e_exec(OS_IMPORT_EXAMPLE, safe_builtins)

0 comments on commit aff8e7a

Please sign in to comment.