manage: Do not use set_defaults on parent parsers with py2
Doing so with cpython < 2.7.9 results in the following bug being hit: argparse set_defaults on subcommands should override top level set_defaults https://bugs.python.org/issue9351 As CentOS 7 continues to ship with cpython 2.7.5 this change simply removes the parent parser call to set_defaults for py2 while leaving the associated tests unchanged. This should ensure that the actual behaviour of placement-manage is unchanged while allowing these tests to pass once again on CentOS. Change-Id: I87989ced31b1d39e30c992b34fe2ae6db06f7883 Closes-Bug: #1804420
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import six
|
||||
import sys
|
||||
|
||||
from oslo_config import cfg
|
||||
@@ -43,7 +44,9 @@ def add_db_command_parsers(subparsers):
|
||||
# help text.
|
||||
subparsers.required = False
|
||||
parser = subparsers.add_parser('db')
|
||||
parser.set_defaults(func=parser.print_help)
|
||||
# Avoid https://bugs.python.org/issue9351 with cpython < 2.7.9
|
||||
if not six.PY2:
|
||||
parser.set_defaults(func=parser.print_help)
|
||||
db_parser = parser.add_subparsers(description='database commands')
|
||||
|
||||
help = _('Sync the datatabse to the current version.')
|
||||
|
||||
Reference in New Issue
Block a user