[issue44655] Confusing error with __slots__

2021-07-16 Thread miss-islington
Change by miss-islington : -- nosy: +miss-islington nosy_count: 2.0 -> 3.0 pull_requests: +25733 pull_request: https://github.com/python/cpython/pull/27198 ___ Python tracker _

[issue44655] Confusing error with __slots__

2021-07-16 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: New changeset 6714dec5e104bdee4a0ed4d9966de27d1bfa1e3d by Pablo Galindo Salgado in branch 'main': bpo-44655: Don't include suggestions for attributes that are the same as the missing one (GH-27197) https://github.com/python/cpython/commit/6714dec5e104

[issue44655] Confusing error with __slots__

2021-07-16 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: > it would be nicer if the version with the suggestion were more like the > version without the suggestion Agreed, but that is actually not related with the suggestions. We only append a string at the end of whatever exception it was there. This diffe

[issue44655] Confusing error with __slots__

2021-07-16 Thread Pablo Galindo Salgado
Change by Pablo Galindo Salgado : -- keywords: +patch pull_requests: +25732 stage: -> patch review pull_request: https://github.com/python/cpython/pull/27197 ___ Python tracker __

[issue44655] Confusing error with __slots__

2021-07-16 Thread Eric V. Smith
Eric V. Smith added the comment: Thanks, Pablo! -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://m

[issue44655] Confusing error with __slots__

2021-07-16 Thread Eric V. Smith
Eric V. Smith added the comment: It's obviously not super important, but it would be nicer if the version with the suggestion were more like the version without the suggestion. Specifically, mentioning the object type: >>> class E: ... __slots__=('a') ... >>> E().a Traceback (most recent

[issue44655] Confusing error with __slots__

2021-07-16 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: > Maybe don't print the "Did you mean" part if the suggestion is the same as > the requested attribute? I think this is a good idea and will take care of many other similar cases. Thanks for the suggestion, Eric! I will prepare a PR -- _

[issue44655] Confusing error with __slots__

2021-07-16 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: For attribute errors we just call dir() on the object and we do a suggestion based on the names so if a name appears in the dir() then we will consider it for the suggestion. -- ___ Python tracker

[issue44655] Confusing error with __slots__

2021-07-16 Thread Eric V. Smith
Eric V. Smith added the comment: Also, the dot after the first 'b' was confusing to me: I thought it had something to do with an attribute of b. And the quotes around the second 'b' were also confusing, but that's mostly because the original example initialized a class variable named 'b' wit

[issue44655] Confusing error with __slots__

2021-07-16 Thread Eric V. Smith
New submission from Eric V. Smith : This is related to issue 44649. This is the simplest non-dataclasses case I could come up with. Given: class Example: __slots__ = ('a', 'b') def __init__(self, a): self.a = a obj = Example(42) print(obj.b) I get this in 3.10 and main: Tra