From af923e261bacbaf0bfb4be77a57d3604cf7e9291 Mon Sep 17 00:00:00 2001 From: enkore Date: Sat, 17 Dec 2016 15:23:47 +0100 Subject: [PATCH 1/2] conftest: pytest 2 compat --- conftest.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/conftest.py b/conftest.py index 197af6fd1..596a4b21f 100644 --- a/conftest.py +++ b/conftest.py @@ -5,7 +5,8 @@ import sys import pytest # needed to get pretty assertion failures in unit tests: -pytest.register_assert_rewrite('borg.testsuite') +if hasattr(pytest, 'register_assert_rewrite'): + pytest.register_assert_rewrite('borg.testsuite') # This is a hack to fix path problems because "borg" (the package) is in the source root. # When importing the conftest an "import borg" can incorrectly import the borg from the From e28b470cfb72a99528e8f665ca89332248d0918d Mon Sep 17 00:00:00 2001 From: Marian Beermann Date: Sat, 17 Dec 2016 18:00:03 +0100 Subject: [PATCH 2/2] 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. --- borg/archiver.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/borg/archiver.py b/borg/archiver.py index 5ee612972..2cdfe37f3 100644 --- a/borg/archiver.py +++ b/borg/archiver.py @@ -1160,7 +1160,7 @@ class Archiver: help='manage repository key') key_parsers = subparser.add_subparsers(title='required arguments', metavar='') - 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='') - 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