From 3cba8da0e08a255d64cb4ccb05018c0c9cc2c58f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20K=C3=A4ufl?= Date: Mon, 10 Sep 2018 19:51:32 +0200 Subject: [PATCH 1/3] Document support for Python 3.7 --- .travis.yml | 8 ++++---- README.md | 2 +- setup.py | 1 + tox.ini | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 52223bdb9..79e314b8e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,14 +4,14 @@ python: - "3.4" - "3.5" - "3.6" - - "3.6-dev" - - "3.7-dev" - "nightly" # - "pypy" - won't work as smmap doesn't work (see gitdb/.travis.yml for details) matrix: + include: + - python: 3.7 + dist: xenial + sudo: required allow_failures: - - python: "3.6-dev" - - python: "3.7-dev" - python: "nightly" git: # a higher depth is needed for most of the tests - must be high enough to not actually be shallow diff --git a/README.md b/README.md index 5313f91fb..be7b32d18 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ If it is not in your `PATH`, you can help GitPython find it by setting the `GIT_PYTHON_GIT_EXECUTABLE=` environment variable. * Git (1.7.x or newer) -* Python 2.7 to 3.6. +* Python 2.7 to 3.7. The list of dependencies are listed in `./requirements.txt` and `./test-requirements.txt`. The installer takes care of installing them for you. diff --git a/setup.py b/setup.py index 2703a9cac..cb0300f7b 100755 --- a/setup.py +++ b/setup.py @@ -110,5 +110,6 @@ def _stamp_version(filename): "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", ] ) diff --git a/tox.ini b/tox.ini index ed09c08bf..eb2fe834e 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27,py34,py35,py36,flake8 +envlist = py27,py34,py35,py36,py37,flake8 [testenv] commands = nosetests {posargs} From 979b5efd538e747cbca58885404ab16c1a41440f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20K=C3=A4ufl?= Date: Mon, 10 Sep 2018 21:36:40 +0200 Subject: [PATCH 2/3] The proper way is return, not raise StopIteration See PEP 479[1] which is part of Python 3.7[2]. [1]: https://www.python.org/dev/peps/pep-0479/ [2]: https://docs.python.org/3/whatsnew/3.7.html#changes-in-python-behavior --- git/objects/submodule/base.py | 2 +- git/repo/base.py | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/git/objects/submodule/base.py b/git/objects/submodule/base.py index f37da34aa..446c88fcd 100644 --- a/git/objects/submodule/base.py +++ b/git/objects/submodule/base.py @@ -1160,7 +1160,7 @@ def iter_items(cls, repo, parent_commit='HEAD'): try: parser = cls._config_parser(repo, pc, read_only=True) except IOError: - raise StopIteration + return # END handle empty iterator rt = pc.tree # root tree diff --git a/git/repo/base.py b/git/repo/base.py index 125ab8021..3c5d68540 100644 --- a/git/repo/base.py +++ b/git/repo/base.py @@ -714,7 +714,10 @@ def blame_incremental(self, rev, file, **kwargs): stream = (line for line in data.split(b'\n') if line) while True: - line = next(stream) # when exhausted, causes a StopIteration, terminating this function + try: + line = next(stream) # when exhausted, causes a StopIteration, terminating this function + except StopIteration: + return hexsha, orig_lineno, lineno, num_lines = line.split() lineno = int(lineno) num_lines = int(num_lines) @@ -724,7 +727,10 @@ def blame_incremental(self, rev, file, **kwargs): # for this commit props = {} while True: - line = next(stream) + try: + line = next(stream) + except StopIteration: + return if line == b'boundary': # "boundary" indicates a root commit and occurs # instead of the "previous" tag @@ -749,7 +755,10 @@ def blame_incremental(self, rev, file, **kwargs): # Discard all lines until we find "filename" which is # guaranteed to be the last line while True: - line = next(stream) # will fail if we reach the EOF unexpectedly + try: + line = next(stream) # will fail if we reach the EOF unexpectedly + except StopIteration: + return tag, value = line.split(b' ', 1) if tag == b'filename': orig_filename = value From bf00902a9cb3645730ceaa2ac63dcecca4db409e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20K=C3=A4ufl?= Date: Sun, 14 Oct 2018 23:55:49 +0200 Subject: [PATCH 3/3] Run tests on travis against an up-to-date nightly Running "nightly" on trusty (the current default on travis) is not nightly any more, but 3.7.0a4+. See https://docs.travis-ci.com/user/languages/python/#development-releases-support --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 79e314b8e..3c2daf240 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,13 +4,15 @@ python: - "3.4" - "3.5" - "3.6" - - "nightly" # - "pypy" - won't work as smmap doesn't work (see gitdb/.travis.yml for details) matrix: include: - python: 3.7 dist: xenial sudo: required + - python: "nightly" + dist: xenial + sudo: required allow_failures: - python: "nightly" git: