From f3d5df2ce3addd9e9e1863f4f33665a16b415b71 Mon Sep 17 00:00:00 2001 From: Andreas Maier Date: Fri, 21 Oct 2016 11:11:22 +0200 Subject: Fixes to support Python 2.6 again. Details: - Added Python 2.6 again to .travis.yml (it was removed in commit 4486bcb). - Replaced the use of dictionary comprehensions in `git/cmd.py` around line 800 with the code before that change (in commit 25a2ebf). Reason: dict comprehensions were introduced only in Python 2.7. - Changed the import source for `SkipTest` and `skipIf` from `unittest.case` to first trying `unittest` and upon ImportError from `unittest2`. This was done in `git/util.py` and in several testcases. Reason: `SkipTest` and `skipIf` were introduced to unittest only in Python 2.7, and `unittest2` is a backport of `unittest` additions to Python 2.6. - In git/test/lib/helper.py, fixed the definition of `assertRaisesRegex` to work on py26. - For Python 2.6, added the `unittest2` dependency to `requirements.txt` and changed `.travis.yml` to install `unittest2`. Because git/util.py uses SkipTest from unittest/unittest2, the dependency could not be added to `test-requirements.txt`. - Fixed an assertion in `git/test/test_index.py` to also allow a Python 2.6 specific exception message. - In `is_cygwin_git()` in `git/util.py`, replaced `check_output()` with `Popen()`. It was added in Python 2.7. - Enabled Python 2.6 for Windows: - Added Python 2.6 for MINGW in .appveyor.yml. - When defining `PROC_CREATIONFLAGS` in `git/cmd.py`, made use of certain win32 and subprocess flags that were introduced in Python 2.7, dependent on whether we run on Python 2.7 or higher. - In `AutoInterrupt.__del__()` in `git/cmd.py`, allowed for `os` not having `kill()`. `os.kill()` was added for Windows in Python 2.7 (For Linux, it existed in Python 2.6 already). --- git/cmd.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'git/cmd.py') diff --git a/git/cmd.py b/git/cmd.py index 72ba82c3..78b5ff70 100644 --- a/git/cmd.py +++ b/git/cmd.py @@ -139,9 +139,9 @@ def dict_to_slots_and__excluded_are_none(self, d, excluded=()): CREATE_NO_WINDOW = 0x08000000 ## CREATE_NEW_PROCESS_GROUP is needed to allow killing it afterwards, -# seehttps://docs.python.org/3/library/subprocess.html#subprocess.Popen.send_signal +# see https://docs.python.org/3/library/subprocess.html#subprocess.Popen.send_signal PROC_CREATIONFLAGS = (CREATE_NO_WINDOW | subprocess.CREATE_NEW_PROCESS_GROUP - if is_win + if is_win and sys.version_info >= (2, 7) else 0) @@ -245,7 +245,7 @@ class Git(LazyMixin): return # can be that nothing really exists anymore ... - if os is None or os.kill is None: + if os is None or getattr(os, 'kill', None) is None: return # try to kill it @@ -831,8 +831,12 @@ class Git(LazyMixin): :return: Same as ``execute``""" # Handle optional arguments prior to calling transform_kwargs # otherwise these'll end up in args, which is bad. - _kwargs = {k: v for k, v in kwargs.items() if k in execute_kwargs} - kwargs = {k: v for k, v in kwargs.items() if k not in execute_kwargs} + _kwargs = dict() + for kwarg in execute_kwargs: + try: + _kwargs[kwarg] = kwargs.pop(kwarg) + except KeyError: + pass insert_after_this_arg = kwargs.pop('insert_kwargs_after', None) -- cgit v1.2.1