← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1424277] [NEW] Running without arguments results in Exception on Python 3

 

Public bug reported:

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)

** Affects: cloud-init
     Importance: Undecided
         Status: New

** Description changed:

  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'
+     $ 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 chenge of behavior of argparse on Python 3 when
  using subparsers.
  
- Can we workarounded by adding try-catch similar to this one:
+ Can be workarounded by adding try-catch similar to this one:
  
-         try:
-             (name, functor) = args.action
-         except AttributeError:
-             parser.print_help()
-             return 0
+         try:
+             (name, functor) = args.action
+         except AttributeError:
+             parser.print_help()
+             return 0
  
  (Consider it public domain, as it is so simple)

** Description changed:

  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 chenge of behavior of argparse on Python 3 when
+ 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)

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to cloud-init.
https://bugs.launchpad.net/bugs/1424277

Title:
  Running without arguments results in Exception on Python 3

Status in Init scripts for use on cloud images:
  New

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)

To manage notifications about this bug go to:
https://bugs.launchpad.net/cloud-init/+bug/1424277/+subscriptions


Follow ups

References