This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Wrong error message on class instance, when giving too little positional arguments
Type: behavior Stage:
Components: Interpreter Core Versions: Python 3.2
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, telmich
Priority: normal Keywords:

Created on 2011-10-06 11:54 by telmich, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (2)
msg145002 - (view) Author: (telmich) Date: 2011-10-06 11:54
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
msg145006 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2011-10-06 13:22
Fixed in 3.3

Traceback (most recent call last):
  File "x.py", line 16, in <module>
    debug=0)
TypeError: __init__() missing 2 required positional arguments: 'remote_user' and 'remote_prefix'
History
Date User Action Args
2022-04-11 14:57:22adminsetgithub: 57322
2011-10-06 13:22:07benjamin.petersonsetstatus: open -> closed

nosy: + benjamin.peterson
messages: + msg145006

resolution: out of date
2011-10-06 11:54:59telmichcreate