[New-bugs-announce] [issue32448] subscriptable

Alexander Mohr report at bugs.python.org
Fri Dec 29 13:59:48 EST 2017


New submission from Alexander Mohr <thehesiod at gmail.com>:

Currently subscriting a attribute that's None reports the following:
>>> class Foo: pass
>>> Foo.organizer = None
>>> Foo.organizer['start']
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'NoneType' object is not subscriptable

What would be nice is if it were to report the name of the attribute that is not subscriptable as it would greatly help in the logs, something like:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'NoneType' object of attribute 'organizer' is not subscriptable

just a thought.  Otherwise one would need to sprinkle their code with asserts, especially if it's a compound statement like:
Foo.organizer.blah[0], you wouldn't know which attribute wasn't None

----------
components: Interpreter Core
messages: 309187
nosy: thehesiod
priority: normal
severity: normal
status: open
title: subscriptable
type: enhancement
versions: Python 3.7, Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32448>
_______________________________________


More information about the New-bugs-announce mailing list