- Python Home
- About
- News
- Documentation
- Downloads
- Community
- Foundation
- Developer's Guide
- Issue Tracker
- Issues
- Summaries
- User
- Administration
- Help
➜
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.
| Author | serhiy.storchaka |
|---|---|
| Recipients | Anthony Sottile, rhettinger, serhiy.storchaka |
| Date | 2017-09-22.06:26:33 |
| SpamBayes Score | -1.0 |
| Marked as misclassified | Yes |
| Message-id | <1506061593.47.0.497142353818.issue31550@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
|---|
I'm not sure that this is an enhancement. It makes an error message inconsistent with other error messages.
>>> class I(int): pass
...
>>> I()[0]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'I' object does not support indexing
>>> 0[0] = 0
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'int' object does not support item assignment
>>> del 0[0]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'int' object does not support item deletion
>>> ''['']
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: string indices must be integers, not str
>>> iter(0)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'int' object is not iterable
>>> reversed(0)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: argument to reversed() must be a sequence
>>> next(0)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: int object is not an iterator
>>> {}[[]]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unhashable type: 'list'
And actually this message is misleading. An attribute '__getitem__' is not looked up on objects.
>>> class I(int): pass
...
>>> x = I()
>>> x.__getitem__ = lambda *args: None
>>> I()[0:]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'I' object has no attribute '__getitem__'
>>> x.__getitem__
<function <lambda> at 0x7f11b62dd648> |
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2017-09-22 06:26:33 | serhiy.storchaka | set | recipients: + serhiy.storchaka, rhettinger, Anthony Sottile |
| 2017-09-22 06:26:33 | serhiy.storchaka | set | messageid: <1506061593.47.0.497142353818.issue31550@psf.upfronthosting.co.za> |
| 2017-09-22 06:26:33 | serhiy.storchaka | link | issue31550 messages |
| 2017-09-22 06:26:33 | serhiy.storchaka | create |
Powered by Roundup Copyright © 1990-2022, Python Software Foundation
Legal Statements
