This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2017年05月02日 19:31 by dlenski, last changed 2022年04月11日 14:58 by admin. This issue is now closed.
| Messages (5) | |||
|---|---|---|---|
| msg292799 - (view) | Author: Daniel Lenski (dlenski) * | Date: 2017年05月02日 19:31 | |
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.
|
|||
| msg396172 - (view) | Author: Irit Katriel (iritkatriel) * (Python committer) | Date: 2021年06月20日 14:35 | |
There is no way to know through static analysis that the subscript is on an object of type exception. I think this should be closed as won't fix. |
|||
| msg396289 - (view) | Author: Daniel Lenski (dlenski) * | Date: 2021年06月21日 21:14 | |
> There is no way to know through static analysis that the subscript is on an object of type exception. I think this should be closed as won't fix. In almost all cases, the variable in question will receive its value via `except ... as e:`. try: ... except (Exception1, Exception2, ...) as e: e[0] Seems to me that it should be possible for 2to3 to handle this large subset of applicable cases via static analysis. |
|||
| msg404561 - (view) | Author: Daniel Lenski (dlenski) * | Date: 2021年10月21日 01:25 | |
Why was this closed? As I wrote in a previous comment, this situation can be automatically identified and addressed via static analysis in the vastly-predominant case, where the Exception object is assigned via an `exception ... as exc:` clause. |
|||
| msg404566 - (view) | Author: Benjamin Peterson (benjamin.peterson) * (Python committer) | Date: 2021年10月21日 04:48 | |
See the superseding issue; 2to3 is deprecated and headed towards deletion. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:58:45 | admin | set | github: 74424 |
| 2021年10月21日 04:48:00 | benjamin.peterson | set | messages: + msg404566 |
| 2021年10月21日 01:25:46 | dlenski | set | messages: + msg404561 |
| 2021年10月20日 22:53:12 | iritkatriel | set | status: open -> closed superseder: Close 2to3 issues and list them here stage: test needed -> resolved |
| 2021年06月21日 21:14:18 | dlenski | set | status: pending -> open messages: + msg396289 |
| 2021年06月20日 14:35:05 | iritkatriel | set | status: open -> pending nosy: + iritkatriel messages: + msg396172 resolution: wont fix |
| 2018年09月11日 10:02:13 | xtreak | set | nosy:
+ xtreak |
| 2017年05月05日 22:11:14 | terry.reedy | set | nosy:
+ benjamin.peterson stage: test needed |
| 2017年05月02日 19:31:56 | dlenski | create | |