[New-bugs-announce] [issue13113] Wrong error message on class instance, when giving too little positional arguments

telmich report at bugs.python.org
Thu Oct 6 13:55:00 CEST 2011


New submission from telmich <nico-bugs.python.org at schottelius.org>:

I've this class:


class Path:
    """Class that handles path related configurations"""

    def __init__(self,
                target_host,
                remote_user,
                remote_prefix,
                initial_manifest=False,
                base_dir=None,
                debug=False):

That is falsely instantiated from a different class with these arguments:

        self.path = cdist.path.Path(self.target_host, 
                        initial_manifest=initial_manifest,
                        base_dir=home,
                        debug=debug)

Which results in the following traceback:


[13:40] kr:cdist% ./bin/cdist config -d localhost 
Traceback (most recent call last):
  File "./bin/cdist", line 119, in <module>
    commandline()
  File "./bin/cdist", line 102, in commandline
    args.func(args)
  File "/home/users/nico/oeffentlich/rechner/projekte/cdist/lib/cdist/config.py", line 296, in config
    c = Config(host, initial_manifest=args.manifest, home=args.cdist_home, debug=args.debug)
  File "/home/users/nico/oeffentlich/rechner/projekte/cdist/lib/cdist/config.py", line 52, in __init__
    debug=debug)
TypeError: __init__() takes at least 4 arguments (5 given)


Problem:

- there are 5 arguments, so an error message indicating there are at least 4 needed is not helpful

Proposal (pseudocode):

Change to "Only %d of %d required positional arguments given" required_positional, giving_positional

----------
components: Interpreter Core
messages: 145002
nosy: telmich
priority: normal
severity: normal
status: open
title: Wrong error message on class instance, when giving too little positional arguments
type: behavior
versions: Python 3.2

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue13113>
_______________________________________


More information about the New-bugs-announce mailing list