[issue31550] Inconsistent error message for TypeError with subscripting

2018-03-27 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

Marked as closed for the reasons listed.

Thank you for the suggestion, but we're going to decline.

--
resolution:  -> rejected
stage: patch review -> 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



[issue31550] Inconsistent error message for TypeError with subscripting

2018-03-27 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

If the reason of this change was making the error message more consistent with 
other error messages in classic classes (at the cost of larger dereference with 
Python 3), it LGTM.

--

___
Python tracker 

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



[issue31550] Inconsistent error message for TypeError with subscripting

2018-03-19 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

> it's different than python3 (for no good reason?)
Python 3 has new style classes which were always different.

> main concern here is ease in portability  
We've long stated that there should never be dependency on the exact wording of 
an error message.  We're allowed to change that.

> For instance it was consistent in 2.7.1
To the extent we care about this, it is more important to be consistent with 
later releases than earlier releases.

Since I don't see any evidence that there is a real world problem, I would like 
to see this left alone.  At this point, in Python 2.7's life we need to have a 
strong aversion to any changes at all.  Not only has that ship sailed, its 
voyage is almost over.

--
versions: +Python 2.7 -Python 3.7

___
Python tracker 

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



[issue31550] Inconsistent error message for TypeError with subscripting

2018-03-19 Thread Anthony Sottile

Anthony Sottile  added the comment:

I think the main concern here is ease in portability coupled with the 
incorrectness of the current message (pointed out in 
https://bugs.python.org/issue31550#msg302738)

For instance it was consistent in 2.7.1, but not later on in the 2.7.x tree.  
*And* it's different than python3 (for no good reason?)

The message is misleading as well, it's not looking for __getitem__ on the 
instance but on the type.

--

___
Python tracker 

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



[issue31550] Inconsistent error message for TypeError with subscripting

2018-03-19 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

I would like to leave this as-is.  Consistency between error message wording is 
one of our least important considerations.  The __getitem__ message is somewhat 
useful -- it helps learners know which magic method is being called and what 
they would need to add to a class to make it work.  This was the typical 
wording for old-style classes.  For example, calling len() on an old-style 
class without __len__ gave this message, "AttributeError: A instance has no 
attribute '__len__'".

In addition, we are getting very close to end-of-life for Python2.7.  
Accordingly, any changes at this point should be limited to things that really 
matter.  It will be too easy to introduce a new problem that we won't have an 
opportunity to fix later.

I recommend closing this and shifting attention to things that matter.

--
assignee:  -> rhettinger

___
Python tracker 

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



[issue31550] Inconsistent error message for TypeError with subscripting

2018-03-19 Thread Anthony Sottile

Anthony Sottile  added the comment:

I made a new PR which instead *reverts* the python2.7 patch to restore 
consistency

--

___
Python tracker 

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



[issue31550] Inconsistent error message for TypeError with subscripting

2018-03-19 Thread Anthony Sottile

Change by Anthony Sottile :


--
pull_requests: +5909

___
Python tracker 

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



[issue31550] Inconsistent error message for TypeError with subscripting

2017-09-24 Thread Anthony Sottile

Anthony Sottile added the comment:

Shouldn't you wait for Raymond's arguments before outright closing the PR?

--

___
Python tracker 

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



[issue31550] Inconsistent error message for TypeError with subscripting

2017-09-24 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

I think it should. But let to hear Raymond's arguments.

--

___
Python tracker 

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



[issue31550] Inconsistent error message for TypeError with subscripting

2017-09-22 Thread Anthony Sottile

Anthony Sottile added the comment:

All I'm really looking for is consistency -- should the change to 2.7 be 
reverted instead?

--

___
Python tracker 

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



[issue31550] Inconsistent error message for TypeError with subscripting

2017-09-22 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

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 "", line 1, in 
TypeError: 'I' object does not support indexing
>>> 0[0] = 0
Traceback (most recent call last):
  File "", line 1, in 
TypeError: 'int' object does not support item assignment
>>> del 0[0]
Traceback (most recent call last):
  File "", line 1, in 
TypeError: 'int' object does not support item deletion
>>> ''['']  
>>> 
>>> 
>>>  
Traceback (most recent call last):  

 
  File "", line 1, in

 
TypeError: string indices must be integers, not str 

 
>>> iter(0)
Traceback (most recent call last):
  File "", line 1, in 
TypeError: 'int' object is not iterable
>>> reversed(0)
Traceback (most recent call last):
  File "", line 1, in 
TypeError: argument to reversed() must be a sequence
>>> next(0)
Traceback (most recent call last):
  File "", line 1, in 
TypeError: int object is not an iterator
>>> {}[[]]
Traceback (most recent call last):
  File "", line 1, in 
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 "", line 1, in 
TypeError: 'I' object has no attribute '__getitem__'
>>> x.__getitem__
 at 0x7f11b62dd648>

--
nosy: +rhettinger, serhiy.storchaka

___
Python tracker 

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



[issue31550] Inconsistent error message for TypeError with subscripting

2017-09-21 Thread Anthony Sottile

Changes by Anthony Sottile :


--
keywords: +patch
pull_requests: +3679
stage:  -> patch review

___
Python tracker 

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



[issue31550] Inconsistent error message for TypeError with subscripting

2017-09-21 Thread Anthony Sottile

New submission from Anthony Sottile:

There's a bit of history I don't understand and couldn't find the appropriate 
trail for.

The original error message from the 2.6 era:

$ python2.6 -c 0[0]
Traceback (most recent call last):
  File "", line 1, in 
TypeError: 'int' object is unsubscriptable


This was changed in 
https://github.com/python/cpython/commit/f5fd5239819c5dfb1d7a33484be49dc705544d02
 for clarity

As seen in 2.7.1

$ ./python2.7.1 -c 0[0]
Traceback (most recent call last):
  File "", line 1, in 
TypeError: 'int' object is not subscriptable


It was later changed in the 2.7 era here: 
https://github.com/python/cpython/commit/7d1483cbadbe48620964348a2039690624e7dc8e


To this error message (as demonstrated with 2.7.12):

$ python2.7 -c 0[0]
Traceback (most recent call last):
  File "", line 1, in 
TypeError: 'int' object has no attribute '__getitem__'


However, this patch never made it into the 3.x branch:

$ python3.6 -c 0[0]
Traceback (most recent call last):
  File "", line 1, in 
TypeError: 'int' object is not subscriptable


Should this patch be (have been) cherry picked into master?

--
components: Interpreter Core
messages: 302736
nosy: Anthony Sottile
priority: normal
severity: normal
status: open
title: Inconsistent error message for TypeError with subscripting
type: behavior
versions: Python 3.7

___
Python tracker 

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