[issue32448] subscriptable

2018-01-05 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

I agree that a better message would be nice.  But compiling 'a.b[c]' breaks the 
expression apart into the equivalent of 't=a.b; t[c]', where 't' is an 
anonymous reference, so as David notes, there is no 'name' left to display.  We 
don't have a 'not possible resoluton, so "won't fix (because not possible)" 
seems closest.

--
nosy: +terry.reedy
resolution:  -> wont fix
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32448] subscriptable

2017-12-30 Thread R. David Murray

R. David Murray  added the comment:

Well, in that case having 'organizer' in the error message wouldn't help you 
untangle your code ;)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32448] subscriptable

2017-12-30 Thread Alexander Mohr

Alexander Mohr  added the comment:

oh for second example I meant something like this:

>>> class Foo: pass
>>> Foo.organizer = None
>>> Foo.blah = Foo
>>> Foo.blah.organizer = None
>>> Foo.blah.organizer[0]

ya this is just a pie in the sky request :)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32448] subscriptable

2017-12-29 Thread R. David Murray

R. David Murray  added the comment:

At the point at which that error is raised, Python doesn't know the name of the 
attribute, nor is attribute access the only place where that particular error 
report is triggered (it's in a generic subscript-this-object call).  So I doubt 
doing this would be practical.

As for Foo.organizer.blah[0], it has to be blah that is None, since 
'.organizer' is an attribute access and not a subscript operation.  The more 
difficult case is something like getattr(someobject, somevar)[0], where you 
can't tell what somevar contains just from the traceback.  Which is why some 
value-added systems also dump the locals from the frame in the traceback.

--
nosy: +r.david.murray

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32448] subscriptable

2017-12-29 Thread Alexander Mohr

New submission from Alexander Mohr :

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 "", line 1, in 
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 "", line 1, in 
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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com