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
97301a9b
Commit
97301a9b
authored
May 17, 2001
by
Evan Simpson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix "print >>None" and test it.
parent
935c41c4
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
5 deletions
+18
-5
lib/python/RestrictedPython/RestrictionMutator.py
lib/python/RestrictedPython/RestrictionMutator.py
+4
-2
lib/python/RestrictedPython/tests/restricted_module.py
lib/python/RestrictedPython/tests/restricted_module.py
+11
-1
lib/python/RestrictedPython/tests/testRestrictions.py
lib/python/RestrictedPython/tests/testRestrictions.py
+3
-2
No files found.
lib/python/RestrictedPython/RestrictionMutator.py
View file @
97301a9b
...
...
@@ -87,7 +87,7 @@ RestrictionMutator modifies a tree produced by
compiler.transformer.Transformer, restricting and enhancing the
code in various ways before sending it to pycodegen.
'''
__version__
=
'$Revision: 1.
3
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
4
$'
[
11
:
-
2
]
from
compiler
import
ast
from
compiler.transformer
import
parse
...
...
@@ -213,9 +213,11 @@ class RestrictionMutator:
def
visitPrint
(
self
,
node
,
walker
):
node
=
walker
.
defaultVisitNode
(
node
)
if
node
.
dest
is
None
:
self
.
funcinfo
.
_print_used
=
1
if
node
.
dest
is
None
:
node
.
dest
=
_print_target_name
else
:
node
.
dest
=
ast
.
Or
([
node
.
dest
,
_print_target_name
])
return
node
visitPrintnl
=
visitPrint
...
...
lib/python/RestrictedPython/tests/restricted_module.py
View file @
97301a9b
def
print
1
():
def
print
0
():
print
'Hello, world!'
,
return
printed
def
print1
():
print
'Hello,'
,
print
'world!'
,
return
printed
def
print2
():
x
=
None
print
>>
x
,
'Hello, world!'
,
return
printed
def
primes
():
# Somewhat obfuscated code on purpose
print
filter
(
None
,
map
(
lambda
y
:
y
*
reduce
(
lambda
x
,
y
:
x
*
y
!=
0
,
...
...
lib/python/RestrictedPython/tests/testRestrictions.py
View file @
97301a9b
...
...
@@ -170,7 +170,8 @@ class RestrictionTests(unittest.TestCase):
return
func
(
*
args
,
**
kw
)
def
checkPrint
(
self
):
res
=
self
.
execFunc
(
'print1'
)
for
i
in
range
(
3
):
res
=
self
.
execFunc
(
'print%s'
%
i
)
assert
res
==
'Hello, world!'
,
res
def
checkPrimes
(
self
):
...
...
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