[issue38530] Offer suggestions on AttributeError and NameError

2021-05-03 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: New changeset 80a2a4ed7d090fff2584302f07315d567109bca9 by Dennis Sweeney in branch 'master': bpo-38530: Refactor and improve AttributeError suggestions (GH-25776) https://github.com/python/cpython/commit/80a2a4ed7d090fff2584302f07315d567109bca9

[issue38530] Offer suggestions on AttributeError and NameError

2021-05-01 Thread Dennis Sweeney
Dennis Sweeney added the comment: PR 25776 is a work in progress for what it might look like to do a few things: - Make case-swaps half the cost of any other edit - Refactor Levenshtein code to not use memory allocator, and to bail early on no match. - Add comments to Levenshtein distance

[issue38530] Offer suggestions on AttributeError and NameError

2021-05-01 Thread Dennis Sweeney
Change by Dennis Sweeney : -- pull_requests: +24466 pull_request: https://github.com/python/cpython/pull/25776 ___ Python tracker ___

[issue38530] Offer suggestions on AttributeError and NameError

2021-04-30 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: Hi Dennis, this is a fantastic investigation! I think I really like GCC approach here. We may want to invest into porting some of their ideas into our solution. -- ___ Python tracker

[issue38530] Offer suggestions on AttributeError and NameError

2021-04-30 Thread Dennis Sweeney
Dennis Sweeney added the comment: Some research of other projects: LLVM [1][2] --- - Compute Levenshtein - Using O(n) memory rather than O(n^2) - Uses UpperBound = (len(typo) + 2) // 3 GCC [3] --- - Uses Damerau-Levenshtein distance - Counts transpositions like "abcd"

[issue38530] Offer suggestions on AttributeError and NameError

2021-04-26 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: New changeset 284c52da092438522949d6f96d8c1f9ff37f9f00 by Dennis Sweeney in branch 'master': bpo-38530: Require 50% similarity in NameError and AttributeError suggestions (GH-25584)

[issue38530] Offer suggestions on AttributeError and NameError

2021-04-24 Thread Dennis Sweeney
Dennis Sweeney added the comment: I opened PR 25584 to fix this current behavior: >>> v Traceback (most recent call last): File "", line 1, in NameError: name 'v' is not defined. Did you mean: 'id'? >>> vv Traceback (most recent call last): File "", line 1, in NameError: name 'vv' is

[issue38530] Offer suggestions on AttributeError and NameError

2021-04-24 Thread Dennis Sweeney
Change by Dennis Sweeney : -- nosy: +Dennis Sweeney nosy_count: 8.0 -> 9.0 pull_requests: +24304 pull_request: https://github.com/python/cpython/pull/25584 ___ Python tracker

[issue38530] Offer suggestions on AttributeError and NameError

2021-04-19 Thread Pablo Galindo Salgado
Change by Pablo Galindo Salgado : -- pull_requests: +24201 pull_request: https://github.com/python/cpython/pull/25473 ___ Python tracker ___

[issue38530] Offer suggestions on AttributeError and NameError

2021-04-17 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: New changeset 0b1c169c4a009e1094fe5df938d2367e63ebeea0 by Pablo Galindo in branch 'master': bpo-38530: Cover more error paths in error suggestion functions (GH-25462) https://github.com/python/cpython/commit/0b1c169c4a009e1094fe5df938d2367e63ebeea0

[issue38530] Offer suggestions on AttributeError and NameError

2021-04-17 Thread Pablo Galindo Salgado
Change by Pablo Galindo Salgado : -- pull_requests: +24188 pull_request: https://github.com/python/cpython/pull/25462 ___ Python tracker ___

[issue38530] Offer suggestions on AttributeError and NameError

2021-04-17 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: New changeset 3ab4bea5a3ac28820781cf62a768c65370c9054c by Pablo Galindo in branch 'master': bpo-38530: Include builtins in NameError suggestions (GH-25460) https://github.com/python/cpython/commit/3ab4bea5a3ac28820781cf62a768c65370c9054c --

[issue38530] Offer suggestions on AttributeError and NameError

2021-04-17 Thread Pablo Galindo Salgado
Change by Pablo Galindo Salgado : -- pull_requests: +24187 pull_request: https://github.com/python/cpython/pull/25460 ___ Python tracker ___

[issue38530] Offer suggestions on AttributeError and NameError

2021-04-16 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: New changeset 0ad81d4db2f409d72f469d0b74ab597be772a68e by Pablo Galindo in branch 'master': bpo-38530: Match exactly AttributeError and NameError when offering suggestions (GH-25443)

[issue38530] Offer suggestions on AttributeError and NameError

2021-04-16 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: New changeset 3b82cae774638ecf2baaee8fe2cac8fedafb2ca7 by Pablo Galindo in branch 'master': bpo-38530: Properly extend UnboundLocalError from NameError (GH-25444) https://github.com/python/cpython/commit/3b82cae774638ecf2baaee8fe2cac8fedafb2ca7

[issue38530] Offer suggestions on AttributeError and NameError

2021-04-16 Thread Pablo Galindo Salgado
Change by Pablo Galindo Salgado : -- pull_requests: +24174 pull_request: https://github.com/python/cpython/pull/25444 ___ Python tracker ___

[issue38530] Offer suggestions on AttributeError and NameError

2021-04-16 Thread Pablo Galindo Salgado
Change by Pablo Galindo Salgado : -- pull_requests: +24173 pull_request: https://github.com/python/cpython/pull/25443 ___ Python tracker ___

[issue38530] Offer suggestions on AttributeError and NameError

2021-04-15 Thread STINNER Victor
STINNER Victor added the comment: I like the https://docs.python.org/dev/whatsnew/3.10.html#better-error-messages section: well done, thanks ;-) -- ___ Python tracker ___

[issue38530] Offer suggestions on AttributeError and NameError

2021-04-14 Thread Pablo Galindo Salgado
Change by Pablo Galindo Salgado : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker ___

[issue38530] Offer suggestions on AttributeError and NameError

2021-04-14 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: New changeset 3fc65b97d09fd29272fdf60d2e567bfb070da824 by Pablo Galindo in branch 'master': bpo-38530: Optimize the calculation of string sizes when offering suggestions (GH-25412)

[issue38530] Offer suggestions on AttributeError and NameError

2021-04-14 Thread Pablo Galindo Salgado
Change by Pablo Galindo Salgado : -- pull_requests: +24144 pull_request: https://github.com/python/cpython/pull/25412 ___ Python tracker ___

[issue38530] Offer suggestions on AttributeError and NameError

2021-04-14 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: New changeset e07f4ab26aaf08f90ebd9e6004af14fd6ef39351 by Pablo Galindo in branch 'master': bpo-38530: Make sure that failing to generate suggestions on failure will not propagate exceptions (GH-25408)

[issue38530] Offer suggestions on AttributeError and NameError

2021-04-14 Thread Pablo Galindo Salgado
Change by Pablo Galindo Salgado : -- pull_requests: +24141 pull_request: https://github.com/python/cpython/pull/25408 ___ Python tracker ___

[issue38530] Offer suggestions on AttributeError and NameError

2021-04-14 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: New changeset 5bf8bf2267cd109970b2d946d43b2e9f71379ba2 by Pablo Galindo in branch 'master': bpo-38530: Offer suggestions on NameError (GH-25397) https://github.com/python/cpython/commit/5bf8bf2267cd109970b2d946d43b2e9f71379ba2 --

[issue38530] Offer suggestions on AttributeError and NameError

2021-04-14 Thread Andre Roberge
Change by Andre Roberge : -- nosy: +aroberge ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue38530] Offer suggestions on AttributeError and NameError

2021-04-13 Thread Pablo Galindo Salgado
Change by Pablo Galindo Salgado : -- pull_requests: +24129 pull_request: https://github.com/python/cpython/pull/25397 ___ Python tracker ___

[issue38530] Offer suggestions on AttributeError and NameError

2021-04-13 Thread Pablo Galindo Salgado
Change by Pablo Galindo Salgado : -- title: Offer suggestions on AttributeError -> Offer suggestions on AttributeError and NameError ___ Python tracker ___

[issue38530] Offer suggestions on AttributeError

2021-04-13 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: New changeset 37494b441aced0362d7edd2956ab3ea7801e60c8 by Pablo Galindo in branch 'master': bpo-38530: Offer suggestions on AttributeError (#16856) https://github.com/python/cpython/commit/37494b441aced0362d7edd2956ab3ea7801e60c8 --

[issue38530] Offer suggestions on AttributeError

2020-01-14 Thread STINNER Victor
STINNER Victor added the comment: Related issue: PEP 534 -- Improved Errors for Missing Standard Library Modules https://www.python.org/dev/peps/pep-0534/ -- ___ Python tracker

[issue38530] Offer suggestions on AttributeError

2019-10-28 Thread STINNER Victor
STINNER Victor added the comment: > Ruby has it integrated into the core : > https://bugs.ruby-lang.org/issues/11252 . It was initially a gem that got > merged into core. GCC also provides more and more hints. Example: int main() { int hello = 1; return helo; } GCC: error: 'helo'

[issue38530] Offer suggestions on AttributeError

2019-10-28 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: > Helping the developer to suggest a fix introduces a minor but non-zero > overhead, I would prefer to only enable it as an opt-in option. Maybe enable > it using in the development mode (-X dev/PYTHONDEVMODE=1)? I think doing that would make it lose

[issue38530] Offer suggestions on AttributeError

2019-10-28 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: > By the way, does IPython have a feature like this? Not that I know of. > In short, https://github.com/SylvainDe/DidYouMean-Python seems to already > implement this issue in the proper way, no? I briefly checked the project. My current approach

[issue38530] Offer suggestions on AttributeError

2019-10-28 Thread STINNER Victor
STINNER Victor added the comment: Helping the developer to suggest a fix introduces a minor but non-zero overhead, I would prefer to only enable it as an opt-in option. Maybe enable it using in the development mode (-X dev/PYTHONDEVMODE=1)? > https://github.com/dutc/didyoumean (by James

[issue38530] Offer suggestions on AttributeError

2019-10-27 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Interesting, why locals are not cleared when an exception leaves a frame? -- ___ Python tracker ___

[issue38530] Offer suggestions on AttributeError

2019-10-27 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: I think I am going to proceed to modify PR 16856 by adding the name and the object to the AttributeError exceptions. This should not extend the lifetime of the object more than the current exception is doing as the exception keeps alive the whole

[issue38530] Offer suggestions on AttributeError

2019-10-27 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: I think I am going to proceed modifying PR 16858 by adding the name and the object to the AttributeError exceptions. This should not extend the lifetime of the object more than the current exception is doing as the exception keeps alive the whole

[issue38530] Offer suggestions on AttributeError

2019-10-27 Thread Pablo Galindo Salgado
Change by Pablo Galindo Salgado : -- Removed message: https://bugs.python.org/msg355498 ___ Python tracker ___ ___ Python-bugs-list

[issue38530] Offer suggestions on AttributeError

2019-10-19 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: With the new approach, there is no measurable different in performance: venv ❯ pyperf compare_to json/2019-10-19_20-01-master-24dc2f8c5669.json.gz json/2019-10-20_01-32-suggestions2-21404456383b.json.gz -G Slower (3): - 2to3: 400 ms +- 2 ms -> 405 ms

[issue38530] Offer suggestions on AttributeError

2019-10-19 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: I have opened PR 16856 adding fields to the AttributeError and implementing the feature in PyErr_Display. -- ___ Python tracker ___

[issue38530] Offer suggestions on AttributeError

2019-10-19 Thread Pablo Galindo Salgado
Change by Pablo Galindo Salgado : -- pull_requests: +16403 pull_request: https://github.com/python/cpython/pull/16856 ___ Python tracker ___

[issue38530] Offer suggestions on AttributeError

2019-10-19 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: > But the problem is that making a reference to the object we can prolong its > lifetime and even create a reference loop. If I'm not mistaken, as long as the traceback is alive, the object is alive beacuse the frames will contain it. The other case

[issue38530] Offer suggestions on AttributeError

2019-10-19 Thread Pablo Galindo Salgado
Change by Pablo Galindo Salgado : -- Removed message: https://bugs.python.org/msg354974 ___ Python tracker ___ ___ Python-bugs-list

[issue38530] Offer suggestions on AttributeError

2019-10-19 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: > But the problem is that making a reference to the object we can prolong its > lifetime and even create a reference loop. If I'm not mistaken, as long as the traceback is alive, the object is alive beacuse the frames will contain it. The other case

[issue38530] Offer suggestions on AttributeError

2019-10-19 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: See issue18156, issue22716 and PEP 473. -- ___ Python tracker ___ ___ Python-bugs-list mailing

[issue38530] Offer suggestions on AttributeError

2019-10-19 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: > Why private? They should be public. I was suggesting orivate for now until the/a PEP to modify the exception is approved. In this way we could try to implement the feature that way. -- On the other hand do you see any way to make the current

[issue38530] Offer suggestions on AttributeError

2019-10-19 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Why private? They should be public. But the problem is that making a reference to the object we can prolong its lifetime and even create a reference loop. There was a proposition to create a weak reference, but not all types support weak reference.

[issue38530] Offer suggestions on AttributeError

2019-10-19 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: I will also repeat the pyperformance results locally just in case something was off on the speed.python.org server. -- ___ Python tracker

[issue38530] Offer suggestions on AttributeError

2019-10-19 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: Serhiy, do you think we could attach the object and the name to some private fields of the AttributeError and check that in sys.excepthook if they are present? -- ___ Python tracker

[issue38530] Offer suggestions on AttributeError

2019-10-19 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I am surprised that it was SO expensive. Pathlib would largely benefit from cached_property if it be compatible with slots. -- ___ Python tracker

[issue38530] Offer suggestions on AttributeError

2019-10-19 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: AFAIK there is existing issue for this idea. I have doubts about performance. I added _PyObject_LookupAttr in particularly to avoid an overhead of raising and silencing an AttributeError. I believe most performance sensitive code in the core now uses it

[issue38530] Offer suggestions on AttributeError

2019-10-19 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: Slower (27): - pathlib: 25.2 ms +- 0.4 ms -> 105 ms +- 2 ms: 4.18x slower (+318%) - sympy_str: 315 ms +- 3 ms -> 500 ms +- 3 ms: 1.59x slower (+59%) - sympy_sum: 203 ms +- 2 ms -> 286 ms +- 2 ms: 1.41x slower (+41%) - sqlalchemy_imperative: 36.5 ms +-

[issue38530] Offer suggestions on AttributeError

2019-10-19 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: I am running pyperformance to check the performance cost of this. -- ___ Python tracker ___

[issue38530] Offer suggestions on AttributeError

2019-10-19 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: Idea: we could only do this in interactive mode if we consider that is expensive enough. -- ___ Python tracker ___

[issue38530] Offer suggestions on AttributeError

2019-10-19 Thread Karthikeyan Singaravelan
Karthikeyan Singaravelan added the comment: Ruby has it integrated into the core : https://bugs.ruby-lang.org/issues/11252 . It was initially a gem that got merged into core. > methosd undefined local variable or method `methosd' for main:Object Did you mean? methods method

[issue38530] Offer suggestions on AttributeError

2019-10-19 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: I am not super convinced that this is a great idea because it has some performance cost (although somewhat controlled) but I want to open a discussion. -- ___ Python tracker

[issue38530] Offer suggestions on AttributeError

2019-10-19 Thread Karthikeyan Singaravelan
Change by Karthikeyan Singaravelan : -- nosy: +xtreak ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue38530] Offer suggestions on AttributeError

2019-10-19 Thread Batuhan
Change by Batuhan : -- nosy: +james ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue38530] Offer suggestions on AttributeError

2019-10-19 Thread Batuhan
Batuhan added the comment: It already exists as a 3rd party module and it would be really cool to have this in core level. https://github.com/dutc/didyoumean (by James Powell) -- nosy: +BTaskaya ___ Python tracker

[issue38530] Offer suggestions on AttributeError

2019-10-19 Thread Pablo Galindo Salgado
Change by Pablo Galindo Salgado : -- nosy: +serhiy.storchaka, vstinner ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue38530] Offer suggestions on AttributeError

2019-10-19 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: PR 16850 shows an initial prototype for the idea -- ___ Python tracker ___ ___

[issue38530] Offer suggestions on AttributeError

2019-10-19 Thread Pablo Galindo Salgado
Change by Pablo Galindo Salgado : -- keywords: +patch pull_requests: +16400 stage: -> patch review pull_request: https://github.com/python/cpython/pull/16850 ___ Python tracker

[issue38530] Offer suggestions on AttributeError

2019-10-19 Thread Pablo Galindo Salgado
New submission from Pablo Galindo Salgado : To improve the debugging experience in both interactive and non-interactive code, I propose to offer suggestions when attribute access fails. For example: >>> class A: foo = None ... >>> A.fou Traceback (most recent call last): File "", line 1,