/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/commands.py

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2020-02-03 23:21:15 UTC
  • mfrom: (7290.42.6 paramiko-compat)
  • Revision ID: breezy.the.bot@gmail.com-20200203232115-g7k11bhsfeiqcprv
Fix compatibility with newer versions of paramiko, which break on noise before keys in pem files.

Merged from https://code.launchpad.net/~jelmer/brz/paramiko-compat/+merge/378480

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
# TODO: Specific "examples" property on commands for consistent formatting.
25
25
 
26
 
import contextlib
27
26
import os
28
27
import sys
29
28
 
39
38
 
40
39
import breezy
41
40
from breezy import (
 
41
    cleanup,
42
42
    cmdline,
43
43
    debug,
44
44
    trace,
52
52
from .option import Option
53
53
from .plugin import disable_plugins, load_plugins, plugin_name
54
54
from . import errors, registry
 
55
from .sixish import (
 
56
    string_types,
 
57
    )
55
58
 
56
59
 
57
60
class BzrOptionError(errors.BzrCommandError):
713
716
        r = Option.STD_OPTIONS.copy()
714
717
        std_names = set(r)
715
718
        for o in self.takes_options:
716
 
            if isinstance(o, str):
 
719
            if isinstance(o, string_types):
717
720
                o = option.Option.OPTIONS[o]
718
721
            r[o.name] = o
719
722
            if o.name in std_names:
780
783
            for hook in Command.hooks['pre_command']:
781
784
                hook(self)
782
785
            try:
783
 
                with contextlib.ExitStack() as self._exit_stack:
 
786
                with cleanup.ExitStack() as self._exit_stack:
784
787
                    return class_run(*args, **kwargs)
785
788
            finally:
786
789
                for hook in Command.hooks['post_command']:
1257
1260
    try:
1258
1261
        # ensure all arguments are unicode strings
1259
1262
        for a in argv:
1260
 
            if not isinstance(a, str):
 
1263
            if not isinstance(a, string_types):
1261
1264
                raise ValueError('not native str or unicode: %r' % (a,))
 
1265
            if isinstance(a, bytes):
 
1266
                # For Python 2 only allow ascii native strings
 
1267
                a = a.decode('ascii')
1262
1268
            new_argv.append(a)
1263
1269
    except (ValueError, UnicodeDecodeError):
1264
1270
        raise errors.BzrError("argv should be list of unicode strings.")