Running without arguments results in Exception on Python 3

Bug #1424277 reported by Miro Hrončok
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
cloud-init
Fix Released
Undecided
Dan Watkins

Bug Description

I'm trying to run the current trunk on Python 3. When I run cloud-init with no arguments, I get the following exception.

    $ python3 bin/cloud-init
    Traceback (most recent call last):
      File "bin/cloud-init", line 623, in <module>
        sys.exit(main())
      File "bin/cloud-init", line 614, in main
        (name, functor) = args.action
    AttributeError: 'Namespace' object has no attribute 'action'

This is caused by a change of behavior of argparse on Python 3 when using subparsers.

Can be workarounded by adding try-catch similar to this one:

        try:
            (name, functor) = args.action
        except AttributeError:
            parser.print_help()
            return 0

(Consider it public domain, as it is so simple)

Related branches

description: updated
description: updated
Dan Watkins (oddbloke)
Changed in cloud-init:
status: New → In Progress
assignee: nobody → Daniel Watkins (daniel-thewatkins)
Dan Watkins (oddbloke)
Changed in cloud-init:
status: In Progress → Fix Committed
Dan Watkins (oddbloke)
Changed in cloud-init:
status: Fix Committed → Fix Released
Revision history for this message
James Falcon (falcojr) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.