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
43726a52
Commit
43726a52
authored
Oct 28, 1999
by
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a patch to careful_mul to fix a problem with sequence multiplication.
parent
95daedfa
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
6 deletions
+12
-6
lib/python/DocumentTemplate/VSEval.py
lib/python/DocumentTemplate/VSEval.py
+12
-6
No files found.
lib/python/DocumentTemplate/VSEval.py
View file @
43726a52
...
...
@@ -84,8 +84,8 @@
##############################################################################
"""Very Safe Python Expressions
"""
__rcs_id__
=
'$Id: VSEval.py,v 1.2
2 1999/08/03 20:09:02 jim
Exp $'
__version__
=
'$Revision: 1.2
2
$'
[
11
:
-
2
]
__rcs_id__
=
'$Id: VSEval.py,v 1.2
3 1999/10/28 18:02:41 brian
Exp $'
__version__
=
'$Revision: 1.2
3
$'
[
11
:
-
2
]
from
string
import
translate
,
strip
import
string
...
...
@@ -100,18 +100,24 @@ def default_slicer(env, s, *ind):
return
s
[:]
def
careful_mul
(
env
,
*
factors
):
# r = result (product of all factors)
# c = count (product of all non-sequence factors)
# s flags whether any of the factors is a sequence
r
=
c
=
1
s
=
None
r
=
1
for
factor
in
factors
:
try
:
l
=
len
(
factor
)
s
=
1
except
:
l
=
factor
if
s
and
(
l
*
r
)
>
1000
:
raise
TypeError
,
'Illegal sequence repeat'
except
TypeError
:
c
=
c
*
factor
if
s
and
c
>
1000
:
raise
TypeError
,
\
'Illegal sequence repeat (too many repetitions: %d)'
%
c
r
=
r
*
factor
return
r
default_globals
=
{
'__builtins__'
:{},
'__guarded_mul__'
:
careful_mul
,
...
...
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