Fix regression in error message introduced in bpo-29951. by serhiy-storchaka · Pull Request #2028 · python/cpython

@serhiy-storchaka

@serhiy-storchaka

vstinner

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.

@serhiy-storchaka

vstinner


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)

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?)

@serhiy-storchaka

vstinner

@vstinner

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