diff options
author | Sebastian Thiel <sebastian.thiel@icloud.com> | 2021-03-13 23:13:29 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-13 23:13:29 +0800 |
commit | 48c1e9b430cc84366f2c29bb0006e9593659835e (patch) | |
tree | 86872e4cbd9f45ce5c0da120a0fb52c6c9b0aea2 /git/cmd.py | |
parent | 63c31b60acf2286095109106a4e9b2a4289ec91f (diff) | |
parent | 5df76d451ff0fde14ab71b38030b6c3e6bc79c08 (diff) | |
download | gitpython-48c1e9b430cc84366f2c29bb0006e9593659835e.tar.gz |
Merge pull request #1193 from bertwesarg/revert-sorted-kwargs
Restore order of operators before executing the git command only for < py3.6
Diffstat (limited to 'git/cmd.py')
-rw-r--r-- | git/cmd.py | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -19,6 +19,7 @@ import sys import threading from collections import OrderedDict from textwrap import dedent +import warnings from git.compat import ( defenc, @@ -902,8 +903,14 @@ class Git(LazyMixin): def transform_kwargs(self, split_single_char_options=True, **kwargs): """Transforms Python style kwargs into git command line options.""" + # Python 3.6 preserves the order of kwargs and thus has a stable + # order. For older versions sort the kwargs by the key to get a stable + # order. + if sys.version_info[:2] < (3, 6): + kwargs = OrderedDict(sorted(kwargs.items(), key=lambda x: x[0])) + warnings.warn("Python 3.5 support is deprecated. It does not preserve the order\n" + + "for key-word arguments. Thus they will be sorted!!") args = [] - kwargs = OrderedDict(sorted(kwargs.items(), key=lambda x: x[0])) for k, v in kwargs.items(): if isinstance(v, (list, tuple)): for value in v: |