Commit 1fed785b authored by Stefan Behnel's avatar Stefan Behnel

fix some unnecessary Py2-isms in the code base

parent b3fa3005
...@@ -678,7 +678,7 @@ def cythonize(module_list, exclude=[], nthreads=0, aliases=None, quiet=False, fo ...@@ -678,7 +678,7 @@ def cythonize(module_list, exclude=[], nthreads=0, aliases=None, quiet=False, fo
options['include_path'] = ['.'] options['include_path'] = ['.']
if 'common_utility_include_dir' in options: if 'common_utility_include_dir' in options:
if options.get('cache'): if options.get('cache'):
raise NotImplementedError, "common_utility_include_dir does not yet work with caching" raise NotImplementedError("common_utility_include_dir does not yet work with caching")
if not os.path.exists(options['common_utility_include_dir']): if not os.path.exists(options['common_utility_include_dir']):
os.makedirs(options['common_utility_include_dir']) os.makedirs(options['common_utility_include_dir'])
c_options = CompilationOptions(**options) c_options = CompilationOptions(**options)
......
...@@ -267,12 +267,12 @@ except ImportError: ...@@ -267,12 +267,12 @@ except ImportError:
for name, value in kwd_values.items(): for name, value in kwd_values.items():
if name in args: if name in args:
if name in all: if name in all:
raise TypeError, "Duplicate argument %s" % name raise TypeError("Duplicate argument %s" % name)
all[name] = kwd_values.pop(name) all[name] = kwd_values.pop(name)
if kwds is not None: if kwds is not None:
all[kwds] = kwd_values all[kwds] = kwd_values
elif kwd_values: elif kwd_values:
raise TypeError, "Unexpected keyword arguments: %s" % kwd_values.keys() raise TypeError("Unexpected keyword arguments: %s" % kwd_values.keys())
if defaults is None: if defaults is None:
defaults = () defaults = ()
first_default = len(args) - len(defaults) first_default = len(args) - len(defaults)
...@@ -281,7 +281,7 @@ except ImportError: ...@@ -281,7 +281,7 @@ except ImportError:
if ix >= first_default: if ix >= first_default:
all[name] = defaults[ix - first_default] all[name] = defaults[ix - first_default]
else: else:
raise TypeError, "Missing argument: %s" % name raise TypeError("Missing argument: %s" % name)
return all return all
def get_body(source): def get_body(source):
......
...@@ -159,7 +159,7 @@ def report_error(err): ...@@ -159,7 +159,7 @@ def report_error(err):
echo_file.write(line.encode('ASCII', 'replace')) echo_file.write(line.encode('ASCII', 'replace'))
num_errors = num_errors + 1 num_errors = num_errors + 1
if Options.fast_fail: if Options.fast_fail:
raise AbortError, "fatal errors" raise AbortError("fatal errors")
def error(position, message): def error(position, message):
#print "Errors.error:", repr(position), repr(message) ### #print "Errors.error:", repr(position), repr(message) ###
......
...@@ -798,7 +798,7 @@ class ControlFlowAnalysis(CythonTransform): ...@@ -798,7 +798,7 @@ class ControlFlowAnalysis(CythonTransform):
return node return node
def visit_AssignmentNode(self, node): def visit_AssignmentNode(self, node):
raise InternalError, "Unhandled assignment node" raise InternalError("Unhandled assignment node")
def visit_SingleAssignmentNode(self, node): def visit_SingleAssignmentNode(self, node):
self._visit(node.rhs) self._visit(node.rhs)
...@@ -1097,7 +1097,7 @@ class ControlFlowAnalysis(CythonTransform): ...@@ -1097,7 +1097,7 @@ class ControlFlowAnalysis(CythonTransform):
return node return node
def visit_LoopNode(self, node): def visit_LoopNode(self, node):
raise InternalError, "Generic loops are not supported" raise InternalError("Generic loops are not supported")
def visit_WithTargetAssignmentStatNode(self, node): def visit_WithTargetAssignmentStatNode(self, node):
self.mark_assignment(node.lhs, node.rhs) self.mark_assignment(node.lhs, node.rhs)
......
...@@ -1970,7 +1970,7 @@ class ExpandInplaceOperators(EnvTransform): ...@@ -1970,7 +1970,7 @@ class ExpandInplaceOperators(EnvTransform):
return node, [node] return node, [node]
elif isinstance(node, ExprNodes.IndexNode): elif isinstance(node, ExprNodes.IndexNode):
if node.is_buffer_access: if node.is_buffer_access:
raise ValueError, "Buffer access" raise ValueError("Buffer access")
base, temps = side_effect_free_reference(node.base) base, temps = side_effect_free_reference(node.base)
index = LetRefNode(node.index) index = LetRefNode(node.index)
return ExprNodes.IndexNode(node.pos, base=base, index=index), temps + [index] return ExprNodes.IndexNode(node.pos, base=base, index=index), temps + [index]
...@@ -2304,7 +2304,7 @@ class CreateClosureClasses(CythonTransform): ...@@ -2304,7 +2304,7 @@ class CreateClosureClasses(CythonTransform):
if not from_closure and (self.path or inner_node): if not from_closure and (self.path or inner_node):
if not inner_node: if not inner_node:
if not node.py_cfunc_node: if not node.py_cfunc_node:
raise InternalError, "DefNode does not have assignment node" raise InternalError("DefNode does not have assignment node")
inner_node = node.py_cfunc_node inner_node = node.py_cfunc_node
inner_node.needs_self_code = False inner_node.needs_self_code = False
node.needs_outer_scope = False node.needs_outer_scope = False
......
...@@ -19,7 +19,7 @@ def dumptree(t): ...@@ -19,7 +19,7 @@ def dumptree(t):
def abort_on_errors(node): def abort_on_errors(node):
# Stop the pipeline if there are any errors. # Stop the pipeline if there are any errors.
if Errors.num_errors != 0: if Errors.num_errors != 0:
raise AbortError, "pipeline break" raise AbortError("pipeline break")
return node return node
def parse_stage_factory(context): def parse_stage_factory(context):
......
...@@ -1542,7 +1542,7 @@ class LocalScope(Scope): ...@@ -1542,7 +1542,7 @@ class LocalScope(Scope):
if entry is not None: if entry is not None:
if entry.scope is not self and entry.scope.is_closure_scope: if entry.scope is not self and entry.scope.is_closure_scope:
if hasattr(entry.scope, "scope_class"): if hasattr(entry.scope, "scope_class"):
raise InternalError, "lookup() after scope class created." raise InternalError("lookup() after scope class created.")
# The actual c fragment for the different scopes differs # The actual c fragment for the different scopes differs
# on the outside and inside, so we make a new entry # on the outside and inside, so we make a new entry
entry.in_closure = True entry.in_closure = True
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment