Issue #1 new

range/xrange parameters are handled incorrectly

Anonymous created an issue

Hello. I made the following simple patch to fix the parsing of range/xrange:

{{{ --- pyfrontend.py~ 2010-05-12 23:14:13.000000000 +0200 +++ pyfrontend.py 2011-02-10 11:39:34.092968580 +0100 @@ -350,9 +350,21 @@ body = self.Statements(ast.body) if isinstance(loopexpr,FunctionCall): if loopexpr.fname == "xrange" or loopexpr.fname == 'range': - lwb = loopexpr.args[0] - upb = loopexpr.args[1] - if len(loopexpr.args)==3: + if len(loopexpr.args) == 1: + lwb = Literal(0) + upb = loopexpr.args[0] + step = Literal(1) + elif len(loopexpr.args) == 2: + lwb = loopexpr.args[0] + upb = loopexpr.args[1] + step = Literal(1) + elif len(loopexpr.args) == 3: + lwb = loopexpr.args[0] + upb = loopexpr.args[1] + step = loopexpr.args[2] + else: + raise ValueError("%s only accepts 1, 2 or 3 args but %d found" % (loopexpr.fname, len(loopexpr.args))) + if len(loopexpr.args) == 3: step = loopexpr.args[2] else: step = Literal(1)

}}}

Comments (0)

  1. Log in to comment