classification
Title: Different ValueError for the same operation in List and Tuple
Type: enhancement Stage: resolved
Components: Interpreter Core Versions: Python 3.8
process
Status: closed Resolution: duplicate
Dependencies: Superseder: Non-informative error message in index() and remove() functions
View: 13349
Assigned To: Nosy List: HardikPatel, SilentGhost, larry, serhiy.storchaka, xtreak
Priority: normal Keywords:

Created on 2019-03-26 17:11 by HardikPatel, last changed 2019-03-31 17:10 by serhiy.storchaka. This issue is now closed.

Messages (5)
msg338906 - (view) Author: Hardik (HardikPatel) Date: 2019-03-26 17:11
I am curious why ValueErrors are different in List and Tuple when I try to get an index.  ValueError of a list returns in well format with actual argument "ValueError: 'ITEM' is not in list", whereas tuple returns something like this "ValueError: tuple.index(x): x not in tuple". 
I think List and Tuple both are calling same index() method then why it is raising different ValueErrors? 
>>> jframe_li
['Angular', 'React', 'Vue.js', 'Ember.js', 'Mereor', 'Node.js', 'Backbone.js']
>>> jframe_tu
('Angular', 'React', 'Vue.js', 'Ember.js', 'Mereor', 'Node.js', 'Backbone.js')
>>> jframe_li.index('React')
1
>>> jframe_tu.index('React')
1
>>> jframe_li.index('react')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: 'react' is not in list

>>> jframe_tu.index('react')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: tuple.index(x): x not in tuple
msg338910 - (view) Author: SilentGhost (SilentGhost) * (Python triager) Date: 2019-03-26 18:22
This seems to be related to argument clinic work (issue 20186 and issue 20185).
msg339262 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-03-31 15:57
Thus is definitely is not related to Argument Clinic.

And seems that this issue is a duplicate of an old issue with a long discussion and an unfinished patch, but currently I cannot find that issue.
msg339267 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python triager) Date: 2019-03-31 16:31
> And seems that this issue is a duplicate of an old issue with a long discussion and an unfinished patch, but currently I cannot find that issue.

possibly duplicate of issue13349 which was rejected ?
msg339270 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-03-31 17:10
Yes, it is. Thank you Karthikeyan!
History
Date User Action Args
2019-03-31 17:10:26serhiy.storchakasetstatus: open -> closed
superseder: Non-informative error message in index() and remove() functions
messages: + msg339270

resolution: duplicate
stage: resolved
2019-03-31 16:31:33xtreaksetnosy: + xtreak
messages: + msg339267
2019-03-31 15:57:51serhiy.storchakasettype: behavior -> enhancement
messages: + msg339262
components: - Argument Clinic
versions: + Python 3.8, - Python 3.7
2019-03-26 18:22:56SilentGhostsetnosy: + SilentGhost, larry
messages: + msg338910
components: + Argument Clinic
2019-03-26 18:18:55SilentGhostsetnosy: + serhiy.storchaka
components: + Interpreter Core, - Tests
2019-03-26 17:11:24HardikPatelcreate