[New-bugs-announce] [issue30238] 2to3 doesn't detect or fix Exception indexing

Daniel Lenski report at bugs.python.org
Tue May 2 15:31:56 EDT 2017


New submission from Daniel Lenski:

Python 2.7 allows indexing an Exception object to access its args list.

>>> e=Exception('foo','bar','baz')
>>> assert e[0] is e.args[0]

This doesn't work in 3.5:

>>> e=Exception('foo','bar','baz')
>>> e.args[0]
'foo'
>>> e[0]
TypeError: 'Exception' object is not subscriptable

This conversion (e[x] -> e.args[x]) seems like it ought to be fairly straightforward to support in 2to3.

----------
components: 2to3 (2.x to 3.x conversion tool)
messages: 292799
nosy: dlenski
priority: normal
severity: normal
status: open
title: 2to3 doesn't detect or fix Exception indexing
type: enhancement
versions: Python 2.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue30238>
_______________________________________


More information about the New-bugs-announce mailing list