-
-
Notifications
You must be signed in to change notification settings - Fork 33.1k
Closed as not planned
Closed as not planned
Copy link
Labels
type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
There is a minor inconsistency between the way "not subscriptable" and "not callable" errors are reported.
When an object is not subscriptable, the exception trace includes the carets ~ and ^ for the subscript value and slice.
>>> t = 0
>>> t[0]
Traceback (most recent call last):
File "<python-input-1>", line 1, in <module>
t[0]
~^^^
TypeError: 'int' object is not subscriptable
The carets are also displayed if the attempted subscript is assigned
>>> x = t[0]
Traceback (most recent call last):
File "<python-input-4>", line 1, in <module>
x = t[0]
~^^^
TypeError: 'int' object is not subscriptable
It is the same when an object is not callable
>>> t(0)
Traceback (most recent call last):
File "<python-input-2>", line 1, in <module>
t(0)
~^^^
TypeError: 'int' object is not callable
but when the attempted call is assigned, we lose the carets
>>> x = t(0)
Traceback (most recent call last):
File "<python-input-5>", line 1, in <module>
x = t(0)
TypeError: 'int' object is not callable
instead of the expected
>>> x = t(0)
Traceback (most recent call last):
File "<python-input-5>", line 1, in <module>
x = t(0)
~^^^
TypeError: 'int' object is not callable
CPython versions tested on:
3.13
Operating systems tested on:
Windows
Metadata
Metadata
Assignees
Labels
type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error