Fix subsubparsers for Python <3.4.3

This works around http://bugs.python.org/issue9351

Since Debian and Ubuntu ship 3.4.2 and 3.4.0 respectively.
This commit is contained in:
Marian Beermann 2016-12-17 18:00:03 +01:00
parent 49c05719d8
commit e28b470cfb
1 changed files with 6 additions and 4 deletions

View File

@ -1160,7 +1160,7 @@ class Archiver:
help='manage repository key')
key_parsers = subparser.add_subparsers(title='required arguments', metavar='<command>')
subparser.set_defaults(func=functools.partial(self.do_subcommand_help, subparser))
subparser.set_defaults(fallback_func=functools.partial(self.do_subcommand_help, subparser))
key_export_epilog = textwrap.dedent("""
If repository encryption is used, the repository is inaccessible
@ -1694,7 +1694,7 @@ class Archiver:
help='debugging command (not intended for normal use)')
debug_parsers = subparser.add_subparsers(title='required arguments', metavar='<command>')
subparser.set_defaults(func=functools.partial(self.do_subcommand_help, subparser))
subparser.set_defaults(fallback_func=functools.partial(self.do_subcommand_help, subparser))
debug_info_epilog = textwrap.dedent("""
This command displays some system information that might be useful for bug
@ -1902,11 +1902,13 @@ class Archiver:
def run(self, args):
os.umask(args.umask) # early, before opening files
self.lock_wait = args.lock_wait
setup_logging(level=args.log_level, is_serve=args.func == self.do_serve) # do not use loggers before this!
# This works around http://bugs.python.org/issue9351
func = getattr(args, 'func', None) or getattr(args, 'fallback_func')
setup_logging(level=args.log_level, is_serve=func == self.do_serve) # do not use loggers before this!
check_extension_modules()
if is_slow_msgpack():
logger.warning("Using a pure-python msgpack! This will result in lower performance.")
return args.func(args)
return func(args)
def sig_info_handler(sig_no, stack): # pragma: no cover