[New-bugs-announce] [issue15098] "TypeError" can give a misleading message

Marco Buccini report at bugs.python.org
Sun Jun 17 17:39:28 CEST 2012

New submission from Marco Buccini <marcusbu at gmail.com>:

Suppose that you have an instance method that takes 2 arguments: one is required, while the other is a keyword argument. 

If you call that method without passing the required argument, but instead you only set the keyword argument, then you will get a TypeError exception, claiming this ...
 -> TypeError: 'method' takes at least 2 arguments (2 given)

(I am referring to this particular method: http://www.voidspace.org.uk/python/mock/mock.html#mock.Mock.mock_add_spec)

def test_xyz(self, mocked_popen):

I think the right error message should be different, in particular should be this:
 -> TypeError: 'method' takes at least 2 arguments (1 given)

components: Interpreter Core
messages: 163072
nosy: markon
priority: normal
severity: normal
status: open
title: "TypeError" can give a misleading message
type: behavior
versions: Python 2.7

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list