summaryrefslogtreecommitdiffstats
path: root/lib/kross/python/scripts/RestrictedPython
diff options
context:
space:
mode:
authorSlávek Banko <slavek.banko@axis.cz>2023-01-22 02:02:13 +0100
committerSlávek Banko <slavek.banko@axis.cz>2023-01-22 02:02:13 +0100
commit86480e58eafc1fa3486e03155ed34e02b4595a24 (patch)
tree0e8f64c4003ea558e946b7a3347688904b451635 /lib/kross/python/scripts/RestrictedPython
parent135d005014a1e85295af4e379f026a361537ae5f (diff)
downloadkoffice-86480e58eafc1fa3486e03155ed34e02b4595a24.tar.gz
koffice-86480e58eafc1fa3486e03155ed34e02b4595a24.zip
Drop python2 support in scripts.
Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
Diffstat (limited to 'lib/kross/python/scripts/RestrictedPython')
-rw-r--r--lib/kross/python/scripts/RestrictedPython/Eval.py6
-rw-r--r--lib/kross/python/scripts/RestrictedPython/Guards.py2
-rw-r--r--lib/kross/python/scripts/RestrictedPython/Limits.py12
-rw-r--r--lib/kross/python/scripts/RestrictedPython/MutatingWalker.py2
-rw-r--r--lib/kross/python/scripts/RestrictedPython/RCompile.py4
-rw-r--r--lib/kross/python/scripts/RestrictedPython/RestrictionMutator.py2
6 files changed, 14 insertions, 14 deletions
diff --git a/lib/kross/python/scripts/RestrictedPython/Eval.py b/lib/kross/python/scripts/RestrictedPython/Eval.py
index 841067a1..85802522 100644
--- a/lib/kross/python/scripts/RestrictedPython/Eval.py
+++ b/lib/kross/python/scripts/RestrictedPython/Eval.py
@@ -62,10 +62,10 @@ class RestrictionCapableEval:
self.expr, '<string>')
if PROFILE:
end = clock()
- print 'prepRestrictedCode: %d ms for %s' % (
- (end - start) * 1000, `self.expr`)
+ print('prepRestrictedCode: %d ms for %s' % (
+ (end - start) * 1000, repr(self.expr)))
if err:
- raise SyntaxError, err[0]
+ raise SyntaxError(err[0])
self.used = tuple(used.keys())
self.rcode = co
diff --git a/lib/kross/python/scripts/RestrictedPython/Guards.py b/lib/kross/python/scripts/RestrictedPython/Guards.py
index 4fbdcad1..2338518f 100644
--- a/lib/kross/python/scripts/RestrictedPython/Guards.py
+++ b/lib/kross/python/scripts/RestrictedPython/Guards.py
@@ -93,7 +93,7 @@ def _write_wrapper():
try:
f = getattr(self.ob, secattr)
except AttributeError:
- raise TypeError, error_msg
+ raise TypeError(error_msg)
f(*args)
return handler
class Wrapper:
diff --git a/lib/kross/python/scripts/RestrictedPython/Limits.py b/lib/kross/python/scripts/RestrictedPython/Limits.py
index 3b782e65..4e4511f1 100644
--- a/lib/kross/python/scripts/RestrictedPython/Limits.py
+++ b/lib/kross/python/scripts/RestrictedPython/Limits.py
@@ -25,22 +25,22 @@ def limited_range(iFirst, *args):
elif len(args) == 2:
iStart, iEnd, iStep = iFirst, args[0], args[1]
else:
- raise AttributeError, 'range() requires 1-3 int arguments'
- if iStep == 0: raise ValueError, 'zero step for range()'
+ raise AttributeError('range() requires 1-3 int arguments')
+ if iStep == 0: raise ValueError('zero step for range()')
iLen = int((iEnd - iStart) / iStep)
if iLen < 0: iLen = 0
- if iLen >= RANGELIMIT: raise ValueError, 'range() too large'
- return range(iStart, iEnd, iStep)
+ if iLen >= RANGELIMIT: raise ValueError('range() too large')
+ return list(range(iStart, iEnd, iStep))
limited_builtins['range'] = limited_range
def limited_list(seq):
if isinstance(seq, str):
- raise TypeError, 'cannot convert string to list'
+ raise TypeError('cannot convert string to list')
return list(seq)
limited_builtins['list'] = limited_list
def limited_tuple(seq):
if isinstance(seq, str):
- raise TypeError, 'cannot convert string to tuple'
+ raise TypeError('cannot convert string to tuple')
return tuple(seq)
limited_builtins['tuple'] = limited_tuple
diff --git a/lib/kross/python/scripts/RestrictedPython/MutatingWalker.py b/lib/kross/python/scripts/RestrictedPython/MutatingWalker.py
index b0b8c9ce..7cde295d 100644
--- a/lib/kross/python/scripts/RestrictedPython/MutatingWalker.py
+++ b/lib/kross/python/scripts/RestrictedPython/MutatingWalker.py
@@ -26,7 +26,7 @@ class MutatingWalker:
self._cache = {}
def defaultVisitNode(self, node, walker=None, exclude=None):
- for name, child in node.__dict__.items():
+ for name, child in list(node.__dict__.items()):
if exclude is not None and name in exclude:
continue
v = self.dispatchObject(child)
diff --git a/lib/kross/python/scripts/RestrictedPython/RCompile.py b/lib/kross/python/scripts/RestrictedPython/RCompile.py
index 0a538657..dc5f8d4e 100644
--- a/lib/kross/python/scripts/RestrictedPython/RCompile.py
+++ b/lib/kross/python/scripts/RestrictedPython/RCompile.py
@@ -52,7 +52,7 @@ class RestrictedCompileMode(AbstractCompileMode):
tree = self.parse()
MutatingWalker.walk(tree, self.rm)
if self.rm.errors:
- raise SyntaxError, self.rm.errors[0]
+ raise SyntaxError(self.rm.errors[0])
misc.set_filename(self.filename, tree)
syntax.check(tree)
return tree
@@ -66,7 +66,7 @@ class RestrictedCompileMode(AbstractCompileMode):
def compileAndTuplize(gen):
try:
gen.compile()
- except SyntaxError, v:
+ except SyntaxError as v:
return None, (str(v),), gen.rm.warnings, gen.rm.used_names
return gen.getCode(), (), gen.rm.warnings, gen.rm.used_names
diff --git a/lib/kross/python/scripts/RestrictedPython/RestrictionMutator.py b/lib/kross/python/scripts/RestrictedPython/RestrictionMutator.py
index a8b3850e..d5f4bac0 100644
--- a/lib/kross/python/scripts/RestrictedPython/RestrictionMutator.py
+++ b/lib/kross/python/scripts/RestrictedPython/RestrictionMutator.py
@@ -26,7 +26,7 @@ from SelectCompiler import ast, parse, OP_ASSIGN, OP_DELETE, OP_APPLY
# trees without affecting line numbers shown in tracebacks, etc.
def rmLineno(node):
"""Strip lineno attributes from a code tree."""
- if node.__dict__.has_key('lineno'):
+ if 'lineno' in node.__dict__:
del node.lineno
for child in node.getChildren():
if isinstance(child, ast.Node):