Comment 3 for bug 1354731

Revision history for this message
Daniel Pielmeier (daniel-pielmeier) wrote :

For the developers @hplip. This is a python2 vs. python3 issue.

The problem is the range function used in base/status.py.

From python2 to python python3 the range function got deprecated and the xrange function got renamed to range. So the behaviour changed between the two versions.

python2:
>>> range(1)
[0]
>>> type(range(1))
<type 'list'>
>>> len(range(1))
1

python3:
>>> range(1)
range(0, 1)
>>> type(range(1))
<class 'range'>
>>> len(range(1))
1

In python2 range returned a list. In python3 the function got it's own type.

This is no problem when used in a for loop as you do, but in python2 the last item of the list is one below the number specified for range() and in python3 the last one is the number specified in range() so it tries to iterate over an item which does not exist.

So if you want the same behaviour as in python2 you should probably use list(range(num_pens)) in base/status.py