Skip to content

Fix regression in error message introduced in bpo-29951.#2028

Merged
vstinner merged 3 commits into
python:masterfrom
serhiy-storchaka:getargs-errmsg
Jun 9, 2017
Merged

Fix regression in error message introduced in bpo-29951.#2028
vstinner merged 3 commits into
python:masterfrom
serhiy-storchaka:getargs-errmsg

Conversation

@serhiy-storchaka

Copy link
Copy Markdown
Member

The bug is found by @Haypo.

@serhiy-storchaka serhiy-storchaka added trivial type-bug An unexpected behavior, bug, or error labels Jun 9, 2017

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

If you can, it would be nice to have one unit test for the error message. It seems like this case is not currently tested by test_call.

Comment thread Lib/test/test_call.py

def test_varargs3(self):
msg = r"from_bytes\(\) takes at most 2 positional arguments \(3 given\)"
self.assertRaisesRegex(TypeError, msg, int.from_bytes, b'a', 'little', False)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This unit test is wrong: it doesn't catch the fixed bug. You need to add "^" at the start of the regex.

You may add "^" and "$" to all regex of this file ;-) (Maybe even write an helper function to create the regex?)

@vstinner
vstinner merged commit f9f1cca into python:master Jun 9, 2017
@vstinner

vstinner commented Jun 9, 2017

Copy link
Copy Markdown
Member

Thanks for the fix, but also for your overall work on error messages!

@serhiy-storchaka
serhiy-storchaka deleted the getargs-errmsg branch July 1, 2026 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type-bug An unexpected behavior, bug, or error

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants