replace deprecated argparse.FileType, fixes #9266

also: fix trailing whitespace in archiver.py.
This commit is contained in:
Thomas Waldmann 2026-01-22 17:08:52 +01:00
parent f379420e7c
commit 3630eaafdf
No known key found for this signature in database
GPG key ID: 243ACFA951F78E01

View file

@ -2406,8 +2406,8 @@ class Archiver:
def do_debug_convert_profile(self, args):
"""convert Borg profile to Python profile"""
import marshal
with args.output, args.input:
marshal.dump(msgpack.unpack(args.input, use_list=False, raw=False), args.output)
with open(args.input, 'rb') as input_file, open(args.output, 'wb') as output_file:
marshal.dump(msgpack.unpack(input_file, use_list=False, raw=False), output_file)
@with_repository(lock=False, manifest=False)
def do_break_lock(self, args, repository):
@ -3227,8 +3227,8 @@ class Archiver:
archives and the directory structure below these will be loaded on-demand from
the repository when entering these directories, so expect some delay.
Care should be taken, as Borg backs up symlinks as-is. When an archive
or repository is mounted, it is possible to jump outside the mount point
Care should be taken, as Borg backs up symlinks as-is. When an archive
or repository is mounted, it is possible to jump outside the mount point
by following a symlink. If this happens, files or directories (or versions of them)
that are not part of the archive or repository may appear to be within the mount point.
@ -4140,10 +4140,8 @@ class Archiver:
formatter_class=argparse.RawDescriptionHelpFormatter,
help='convert Borg profile to Python profile (debug)')
subparser.set_defaults(func=self.do_debug_convert_profile)
subparser.add_argument('input', metavar='INPUT', type=argparse.FileType('rb'),
help='Borg profile')
subparser.add_argument('output', metavar='OUTPUT', type=argparse.FileType('wb'),
help='Output file')
subparser.add_argument('input', metavar='INPUT', type=str, help='Borg profile')
subparser.add_argument('output', metavar='OUTPUT', type=str, help='Output file')
# borg delete
delete_epilog = process_epilog("""