Skip to content

Commit

Permalink
Python3: Fix, wasn't properly indicating if range() built-in might ra…
Browse files Browse the repository at this point in the history
…ise.
  • Loading branch information
kayhayen committed Dec 3, 2015
1 parent 8a8c5d2 commit ac08918
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions nuitka/nodes/BuiltinRangeNodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,36 @@ def mayHaveSideEffects(self):

return False

def mayRaiseException(self, exception_type):
for child in self.getVisitableNodes():
if child.mayRaiseException(exception_type):
return True

# TODO: Should take exception_type value into account here.
if child.getIntegerValue() is None:
return True

if python_version >= 270 and \
child.isExpressionConstantRef() and \
type(child.getConstant()) is float:
return True

step = self.getStep()

# A step of 0 will raise.
if step is not None and child.getIntegerValue() == 0:
return True

return False

def computeBuiltinSpec(self, constraint_collection, given_values):
assert self.builtin_spec is not None, self

if not self.builtin_spec.isCompileTimeComputable(given_values):
constraint_collection.onExceptionRaiseExit(BaseException)

# TODO: Raise exception known step 0.

return self, None, None

return constraint_collection.getCompileTimeComputationResult(
Expand Down

0 comments on commit ac08918

Please sign in to comment.