codegen icon indicating copy to clipboard operation
codegen copied to clipboard

Error when parsing ExtSlice

Open DevOlly opened this issue 7 years ago • 2 comments

When parsing complex slicing expressions, like classes[:, :-1], I get this error: File "/usr/local/lib/python3.4/dist-packages/mutpy/codegen.py", line 498, in visit_ExtSlice for idx, item in node.dims: TypeError: 'Slice' object is not iterable

I solved it replacing the visit_ExtSlice method with this: ` def visit_ExtSlice(self, node):

    for i in range(0, len(node.dims)):
        if i > 0:
            self.write(', ')
        self.visit(node.dims[i])`

DevOlly avatar Mar 21 '18 15:03 DevOlly

You will have more issues with complex expressions, so please try astor.

andreif avatar Mar 21 '18 18:03 andreif

Seems there is a missing enumerate() call.

for idx, item in enumerate(node.dims):

serhiy-storchaka avatar Sep 29 '18 15:09 serhiy-storchaka