[issue44166] Make IndexError messages for list more informative

2021-12-05 Thread Raymond Hettinger
Raymond Hettinger added the comment: Thank for the suggestion. While we're going to a pass on this one, no doubt there are other places that language can improve its communication with the user. Please continue to submit ideas and patches. -- __

[issue44166] Make IndexError messages for list more informative

2021-12-05 Thread Raymond Hettinger
Change by Raymond Hettinger : -- assignee: -> rhettinger ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: htt

[issue44166] Make IndexError messages for list more informative

2021-12-05 Thread Raymond Hettinger
Change by Raymond Hettinger : -- resolution: -> rejected stage: patch review -> resolved status: open -> closed ___ Python tracker ___

[issue44166] Make IndexError messages for list more informative

2021-12-05 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: I concur with Serhiy and Raymond and I would prefer to leave as is. -- ___ Python tracker ___

[issue44166] Make IndexError messages for list more informative

2021-12-05 Thread Vedran Čačić
Vedran Čačić added the comment: > fix typically isn't replacing s[i] with s[i - 5] ... especially since that will still raise IndexError (in case when i==15 and len(s)==10). ;-P -- nosy: +veky ___ Python tracker

[issue44166] Make IndexError messages for list more informative

2021-12-05 Thread Raymond Hettinger
Raymond Hettinger added the comment: Here's another way to think of it: The call s[i] raising an IndexError isn't a numerical error, it is a conceptual error. Knowing that i==15 and len(s)==10 doesn't usually help resolve the problem. The fix typically isn't replacing s[i] with s[i - 5].

[issue44166] Make IndexError messages for list more informative

2021-12-05 Thread Raymond Hettinger
Raymond Hettinger added the comment: I also share Serhiy's concerns and prefer that it be left as-is. Conceptually, adding more information in the error message would make it more useful for debugging, but in practice, it would rarely be helpful. In teaching and coaching Python, I've learne

[issue44166] Make IndexError messages for list more informative

2021-12-05 Thread Spencer Brown
Spencer Brown added the comment: One potential solution would be to add two Py_ssize_t to IndexError, storing the index and length along with the existing exception value. Then __str__() can append that to the message if set, perhaps having len be negative to signal they're not passed. An

[issue44166] Make IndexError messages for list more informative

2021-12-05 Thread Andre Roberge
Change by Andre Roberge : -- nosy: +aroberge ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.pyt

[issue44166] Make IndexError messages for list more informative

2021-12-05 Thread Akash Mishra
Akash Mishra added the comment: While browsing some traceback error reporting i land on this solution threads. Specially beginner face traceback error for - KeyError - IndexError (As mentioned in current message thread) - ValueError .. It is sometime self explanatory from error reports but

[issue44166] Make IndexError messages for list more informative

2021-05-20 Thread Rémi Lapeyre
Change by Rémi Lapeyre : -- nosy: +remi.lapeyre ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.p

[issue44166] Make IndexError messages for list more informative

2021-05-18 Thread Miguel Brito
Miguel Brito added the comment: Thanks for your comments, folks! I really appreciate it. I left a comment about this issue in the PR thread: https://github.com/python/cpython/pull/26207#issuecomment-843531990 -- ___ Python tracker

[issue44166] Make IndexError messages for list more informative

2021-05-18 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: I share the same concern as Serhiy, see my comment in the PR: https://github.com/python/cpython/pull/26207#pullrequestreview-661799899 -- ___ Python tracker

[issue44166] Make IndexError messages for list more informative

2021-05-18 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: The problem is that such exceptions are often used with the EAFP style. For example: while stop is None or i < stop: try: v = self[i] if v is value or v == value: return i e

[issue44166] Make IndexError messages for list more informative

2021-05-18 Thread Karthikeyan Singaravelan
Change by Karthikeyan Singaravelan : -- nosy: +pablogsal ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http

[issue44166] Make IndexError messages for list more informative

2021-05-18 Thread Miguel Brito
Change by Miguel Brito : -- keywords: +patch pull_requests: +24824 stage: -> patch review pull_request: https://github.com/python/cpython/pull/26207 ___ Python tracker ___ ___

[issue44166] Make IndexError messages for list more informative

2021-05-18 Thread Miguel Brito
New submission from Miguel Brito : I've noticed that in people will often ask for help on forums or stackoverflow to better understand the causes of IndexErrors [1][2][3]. > The error message line for an IndexError doesn’t give you great > information.[1] Currently, when we access a out of bou