plotSpectrum doesn't take a range() object

Just noticed this change in the latest nightly build (3.8.20170207.2221). My script wants to plot multiple spectra from a workspace.

w=mtd[“workspacename”] # this workspace has 5 spectra or more

Expected behavior

Plot appears with several spectra

Actual behavior

Error message:
TypeError: Incorrect type passed as index argument “xrange(5)”
at line 2 in ‘New script’
caused by line 249 in ‘C:\MantidInstall\bin\’
caused by line 1156 in ‘C:\MantidInstall\bin\’

Steps to reproduce the behavior

See above

Note if I use list(range(5)) or tuple(range(5)) then it works as intended. Something is being picky about the exact types of list objects.

Platforms affected

Tried on Windows, maybe others?

Thanks for this, it appears in some of our early preparations to move to python 3, one of our changes that should not have leaked out has done and affected backward compatibility. Sorry about this, we will fix it before the release on Friday.

The issue for this in github is:

Thanks Nick.

Is there a timetable somewhere for the move to Python 3, from the point of view of users and scientists? We need a suitable opportunity to check and modify our existing scripts, test them with Python 3 inside Mantid, upload the modified versions to the Script Repository and tell the users to download the updates, before they upgrade their Mantid installation to one where Python 3 is the default.

An option somewhere in the Preferences to choose Python 2 or 3 (followed by restarting Mantid) might be appropriate…


I absolutely agree that you will need plenty of warning before we made a change like that!

At the moment we are just making sure that our internal python code is python 3 compatible, we are not moving to python 3 itself yet.

I agree that the next step would be to add a python 3 compatability option for all scripts, and we would also offer to happily update anyones scripts for them if they don’t want to do it themselves.

Please rest assured that we would give 3-4 months notice of any change like that.