[issue30592] Bad error message 'bool()() takes no keyword arguments'

2017-06-08 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: We don't have such code currently. The function name containing "()" looks silly. But funcname is not always a constant string, you can set it to arbitrary string when create a BaseException subclass. -- ___

[issue30592] Bad error message 'bool()() takes no keyword arguments'

2017-06-08 Thread STINNER Victor
STINNER Victor added the comment: > If add an assertion, the user code could provoke a crash by creating an > exception type with a name containing "()": type('E()', (BaseException,), {}). Right. Do we have such code currently? If not, we can remove the assertion later if we want to use such

[issue30592] Bad error message 'bool()() takes no keyword arguments'

2017-06-08 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: If add an assertion, the user code could provoke a crash by creating an exception type with a name containing "()": type('E()', (BaseException,), {}). Thus this should be a runtime check that raises an exception. What the type of an exception should be

[issue30592] Bad error message 'bool()() takes no keyword arguments'

2017-06-08 Thread STINNER Victor
STINNER Victor added the comment: Oh no, I don't expect anything smart :-) Just an assertion to catch obvious mistakes when the function is called manually (not using Argument Clinic). -- ___ Python tracker

[issue30592] Bad error message 'bool()() takes no keyword arguments'

2017-06-08 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: It would be possible to make _PyArg_NoKeywords() adding "()" only if the passed argument don't contain them. But since this is a private API, it was easier to just remove "()" from arguments. In any case most uses of _PyArg_NoKeywords() are generated by

[issue30592] Bad error message 'bool()() takes no keyword arguments'

2017-06-08 Thread STINNER Victor
STINNER Victor added the comment: Would it be possible to add an assertion to _PyArg_NoKeywords() to prevent regressions? Fail if funcname contains "(" or ")". For example: /* funcname must not contain ( or ), since "()" suffix is added in the error message */ assert(!strchr(funcname, '(') &&

[issue30592] Bad error message 'bool()() takes no keyword arguments'

2017-06-08 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: If you know how to write tests for these cases a patch is welcome. But this may be not easy. -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker

[issue30592] Bad error message 'bool()() takes no keyword arguments'

2017-06-08 Thread SylvainDe
SylvainDe added the comment: Hi serhiy.storchaka, this is fine by me! I've added a corresponding comment with questions/suggestions on the Github PR. Do you reckon I should open another ticket for the issue mentionned in my previous message ? I'm happy to take care of it :) --

[issue30592] Bad error message 'bool()() takes no keyword arguments'

2017-06-08 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: New changeset 6cca5c8459cc439cb050010ffa762a03859d3051 by Serhiy Storchaka in branch 'master': bpo-30592: Fixed error messages for some builtins. (#1996) https://github.com/python/cpython/commit/6cca5c8459cc439cb050010ffa762a03859d3051 --

[issue30592] Bad error message 'bool()() takes no keyword arguments'

2017-06-08 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Sorry, SylvainDe, but by the time you expose your desire to work on this issue, I already had written two alternate patches. I needed only a time for deciding what of them is the more appropriate solution. PR 1996 implements the first way. It removes

[issue30592] Bad error message 'bool()() takes no keyword arguments'

2017-06-08 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- pull_requests: +2062 ___ Python tracker ___ ___

[issue30592] Bad error message 'bool()() takes no keyword arguments'

2017-06-08 Thread SylvainDe
SylvainDe added the comment: As I was trying to test coverage for a few places where the same error was built, I have discovered another issue where the error message is very misleading: AssertionError: "^index\(\) takes no keyword arguments$" does not match "index() takes at least 1

[issue30592] Bad error message 'bool()() takes no keyword arguments'

2017-06-07 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Thank you for catching this bug SylvainDe. This is a regression caused by issue30534. I added "()" after the function name for unifying with other error messages but missed that _PyArg_NoKeywords() often is called with argument containing "()", e.g.

[issue30592] Bad error message 'bool()() takes no keyword arguments'

2017-06-07 Thread SylvainDe
SylvainDe added the comment: The issue seems to be in: int _PyArg_NoKeywords(const char *funcname, PyObject *kwargs) I'm happy to submit a PR if needed. -- ___ Python tracker

[issue30592] Bad error message 'bool()() takes no keyword arguments'

2017-06-07 Thread SylvainDe
SylvainDe added the comment: Reproduced locally using unit tests: +def test_varargs0_kw(self): +msg = r"bool\(\) takes no keyword arguments" +self.assertRaisesRegex(TypeError, msg, bool, x=2) + giving: Traceback (most recent call last): File

[issue30592] Bad error message 'bool()() takes no keyword arguments'

2017-06-07 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- assignee: -> serhiy.storchaka components: +Interpreter Core nosy: +serhiy.storchaka type: enhancement -> behavior versions: +Python 3.7 ___ Python tracker

[issue30592] Bad error message 'bool()() takes no keyword arguments'

2017-06-07 Thread SylvainDe
New submission from SylvainDe: Very recent "regression". Issue found because of a pet project trying to parse error messages using regexps : more on https://github.com/SylvainDe/DidYouMean-Python/issues/31 . On recent Cron builds on Jenkins, running the following code