Fix opt error when trying to access a python list with a Type object.

fixes gh-1288

NEWS.txt:
* Fix a warning about and optimization being disabled due to an exception. (Frederic B., reported by John Salvatier)