[issue31506] Improve the error message logic for object_new & object_init

2019-02-19 Thread Nick Coghlan
Nick Coghlan added the comment: The revised behaviour now makes the error messages consistent with each other: >>> class TooManyArgs(): ... def __new__(cls): ... super().__new__(cls, 1) ... >>> TooManyArgs() Traceback (most recent call last): File "", line 1, in File "",

[issue31506] Improve the error message logic for object_new & object_init

2019-02-19 Thread miss-islington
miss-islington added the comment: New changeset 64ca72822338e0ba6e4f14d0a1cd3a9dcfa6c9ac by Miss Islington (bot) in branch '3.7': bpo-31506: Clarify error messages for object.__new__ and object.__init__ (GH-11641)

[issue31506] Improve the error message logic for object_new & object_init

2019-02-19 Thread miss-islington
Change by miss-islington : -- pull_requests: +11963 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue31506] Improve the error message logic for object_new & object_init

2019-02-19 Thread Nick Coghlan
Nick Coghlan added the comment: New changeset 5105483acb3aca318304bed056dcfd7e188fe4b5 by Nick Coghlan (Sanyam Khurana) in branch 'master': bpo-31506: Clarify error messages for object.__new__ and object.__init__ (GH-11641)

[issue31506] Improve the error message logic for object_new & object_init

2019-02-19 Thread Nick Coghlan
Nick Coghlan added the comment: Paolo: it still won't be completely clear, since there's still the subtle issue that __new__ is a static method rather than a class method, so the correct calls up to the base class are respectively: super(Singleton, cls).__new__(cls) # Static method, cls

[issue31506] Improve the error message logic for object_new & object_init

2019-01-21 Thread Sanyam Khurana
Change by Sanyam Khurana : -- pull_requests: +11416, 11417, 11418 stage: needs patch -> patch review ___ Python tracker ___ ___

[issue31506] Improve the error message logic for object_new & object_init

2019-01-21 Thread Sanyam Khurana
Change by Sanyam Khurana : -- pull_requests: +11416, 11417 stage: needs patch -> patch review ___ Python tracker ___ ___

[issue31506] Improve the error message logic for object_new & object_init

2019-01-21 Thread Sanyam Khurana
Change by Sanyam Khurana : -- pull_requests: +11416 stage: needs patch -> patch review ___ Python tracker ___ ___ Python-bugs-list

[issue31506] Improve the error message logic for object_new & object_init

2018-11-27 Thread Paolo Taddonio
Paolo Taddonio added the comment: I am not sure if the following is resolved by your proposal, I post it just in case: The following code works: 1. class Singleton(object): 2. def __new__(cls, *args, **kwargs): 3. if not hasattr(cls, 'instance'): 4.

[issue31506] Improve the error message logic for object_new & object_init

2018-09-24 Thread Nick Coghlan
Nick Coghlan added the comment: We added the method names to help provide a nudge that the issue is likely to be a missing method implementation in the subclassing case, so I'd like to keep them if we can find a way to make the messages accurate again. What if we updated the offending

[issue31506] Improve the error message logic for object_new & object_init

2018-09-22 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I think this change should be reverted. -- ___ Python tracker ___ ___ Python-bugs-list mailing

[issue31506] Improve the error message logic for object_new & object_init

2018-07-31 Thread Karthikeyan Singaravelan
Change by Karthikeyan Singaravelan : -- nosy: +xtreak ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue31506] Improve the error message logic for object_new & object_init

2018-01-04 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Error messages "object.__init__() takes no arguments" and "object.__new__() takes no arguments" are wrong. They contradicts the following error messages: >>> object.__init__() Traceback (most recent call last): File "", line

[issue31506] Improve the error message logic for object_new & object_init

2017-12-11 Thread Sanyam Khurana
Sanyam Khurana added the comment: Serhiy, can you please elaborate on that a bit? I'll try to fix this. -- ___ Python tracker

[issue31506] Improve the error message logic for object_new & object_init

2017-12-10 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: 780acc89bccf332d334a27887684cc942eb6 reintroduced the part of the original bug fixed in a6c0c0695614177c8b6e1840465375eefcfee586. object.__new__() and object.__init__() require an argument (cls and self correspondingly).

[issue31506] Improve the error message logic for object_new & object_init

2017-12-09 Thread Nick Coghlan
Nick Coghlan added the comment: Thanks for the feedback and updates folks! If we decide to make any further changes, I think they will be best handled as a new issue :) -- resolution: -> fixed stage: patch review -> resolved status: open -> closed

[issue31506] Improve the error message logic for object_new & object_init

2017-12-09 Thread Nick Coghlan
Nick Coghlan added the comment: New changeset 780acc89bccf332d334a27887684cc942eb6 by Nick Coghlan (Sanyam Khurana) in branch 'master': bpo-31506: Improve the error message logic for class instantiation (GH-4740)

[issue31506] Improve the error message logic for object_new & object_init

2017-12-06 Thread Sanyam Khurana
Change by Sanyam Khurana : -- pull_requests: +4643 stage: needs patch -> patch review ___ Python tracker ___

[issue31506] Improve the error message logic for object_new & object_init

2017-12-05 Thread Nick Coghlan
Nick Coghlan added the comment: Aye, I think Sanyam's proposed messages look good, and the "C().__init__() takes no arguments" wording is easier to follow than my suggested "C.__init__() takes exactly one argument" wording (as interpreting the latter currently requires

[issue31506] Improve the error message logic for object_new & object_init

2017-12-05 Thread Sanyam Khurana
Sanyam Khurana added the comment: Nick, I think the error messages are incorrect. We expect error message to be `takes no argument` rather than `takes exactly one argument`. Can you please confirm that? I think for the class without any method overrides, the

[issue31506] Improve the error message logic for object_new & object_init

2017-12-05 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I think the main problem is not with coding, but with design. And from this point of view this may be not so easy issue. Let wait until Nick has a time to work on it. -- ___ Python

[issue31506] Improve the error message logic for object_new & object_init

2017-12-05 Thread Sanyam Khurana
Sanyam Khurana added the comment: I'll work on a fix for this and issue a PR. -- nosy: +CuriousLearner ___ Python tracker

[issue31506] Improve the error message logic for object_new & object_init

2017-09-20 Thread Nick Coghlan
Nick Coghlan added the comment: Aye, the "C.__new__" example omitting the first arg was just an error in that example. And that's a good point about the current "object.__init__()" error message actually being incorrect, since the *methods* each take exactly one argument - it's only the

[issue31506] Improve the error message logic for object_new & object_init

2017-09-20 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: C.__new__(42) emits different error, "TypeError: object.__new__(X): X is not a type object (int)". Perhaps you meant C.__new__(C, 42) which now emits "TypeError: C() takes no arguments". Messages "object.__new__() takes no arguments" and "object.__init__()

[issue31506] Improve the error message logic for object_new & object_init

2017-09-19 Thread Nick Coghlan
Nick Coghlan added the comment: I filed issue 31527 as a follow-up issue to see whether or not it might be possible to amend the way these custom errors are generated to benefit from the work that has gone into improving the error responses from PyArg_ParseTupleAndKeywords. --

[issue31506] Improve the error message logic for object_new & object_init

2017-09-19 Thread Nick Coghlan
Nick Coghlan added the comment: Reopening, as I was a little hasty with the merge button: the merged PR *also* changed the `__init__` error message to drop the method name, but I don't think that's what we want. I'm also wondering if we should change the up-call case to *always* report the

[issue31506] Improve the error message logic for object_new & object_init

2017-09-19 Thread Nick Coghlan
Changes by Nick Coghlan : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker ___

[issue31506] Improve the error message logic for object_new & object_init

2017-09-19 Thread Nick Coghlan
Nick Coghlan added the comment: New changeset a6c0c0695614177c8b6e1840465375eefcfee586 by Nick Coghlan (Serhiy Storchaka) in branch 'master': bpo-31506: Improve the error message logic for object.__new__ and object.__init__. (GH-3650)

[issue31506] Improve the error message logic for object_new & object_init

2017-09-19 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- keywords: +patch pull_requests: +3643 stage: needs patch -> patch review ___ Python tracker

[issue31506] Improve the error message logic for object_new & object_init

2017-09-18 Thread Nick Coghlan
Nick Coghlan added the comment: Those would both report "C() takes no parameters" without further enhancements (which would be out of scope for this issue). The proposed improvement here isn't "Let's make the error message exactly correct in all cases" (that's probably impossible, since we've

[issue31506] Improve the error message logic for object_new & object_init

2017-09-18 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: What do you expect for: class C: pass object.__new__(C, 1) C.__new__(C, 1) -- ___ Python tracker ___

[issue31506] Improve the error message logic for object_new & object_init

2017-09-18 Thread Nick Coghlan
Nick Coghlan added the comment: For this issue, I'm not proposing to make any change other than to solve the specific problem reported in the blog post: when the method itself isn't overridden, then the error message should report the name of the most derived class, not "object", to help

[issue31506] Improve the error message logic for object_new & object_init

2017-09-18 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: It is not so easy to make an error message conforming with error messages for similar types. This may require changing error messages in other code. First, "takes no arguments" instead of "takes no parameters". For normal __new__ and __init__ you never got

[issue31506] Improve the error message logic for object_new & object_init

2017-09-18 Thread Nick Coghlan
Nick Coghlan added the comment: Fortunately, the logic is already well encapsulated: there's a "if (excess_args && (case A || case B)) {... report error ...}" check at the start of each of object_new and object_init, where "case A" = "the other function in the object_new/object_init pair has

[issue31506] Improve the error message logic for object_new & object_init

2017-09-18 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Not sure this is easy issue. It requires taking to account many different cases and analyzing many arguments checking code scattered around many files. -- nosy: +serhiy.storchaka ___ Python tracker

[issue31506] Improve the error message logic for object_new & object_init

2017-09-18 Thread Nick Coghlan
Changes by Nick Coghlan : -- keywords: +easy (C) ___ Python tracker ___ ___

[issue31506] Improve the error message logic for object_new & object_init

2017-09-18 Thread Nick Coghlan
Changes by Nick Coghlan : -- components: +Interpreter Core stage: -> needs patch type: -> enhancement versions: +Python 3.7 ___ Python tracker

[issue31506] Improve the error message logic for object_new & object_init

2017-09-18 Thread Nick Coghlan
New submission from Nick Coghlan: As described in https://blog.lerner.co.il/favorite-terrible-python-error-message/, object_new and object_init currently have "object" hardcoded in the error messages they raise for excess parameters: >>> class C: pass ... >>> C(10) Traceback (most recent