diff options
author | cclauss <cclauss@me.com> | 2019-01-21 12:13:56 +0100 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2019-05-05 13:22:53 +0530 |
commit | 14b221bf98757ba61977c1021722eb2faec1d7cc (patch) | |
tree | fb3e0368c5c08e71a42c66b0127d39f6593ad8a2 | |
parent | ce21f63f7acba9b82cea22790c773e539a39c158 (diff) | |
download | gitpython-14b221bf98757ba61977c1021722eb2faec1d7cc.tar.gz |
Update cmd.py, fix PermissionError issue using best practices
This closes #830
-rw-r--r-- | git/cmd.py | 22 |
1 files changed, 9 insertions, 13 deletions
@@ -43,6 +43,10 @@ from .util import ( stream_copy, ) +try: + PermissionError +except NameError: # Python < 3.3 + PermissionError = OSError execute_kwargs = {'istream', 'with_extended_output', 'with_exceptions', 'as_process', 'stdout_as_string', @@ -211,23 +215,15 @@ class Git(LazyMixin): # test if the new git executable path is valid - if sys.version_info < (3,): - # - a GitCommandNotFound error is spawned by ourselves - # - a OSError is spawned if the git executable provided - # cannot be executed for whatever reason - exceptions = (GitCommandNotFound, OSError) - else: - # - a GitCommandNotFound error is spawned by ourselves - # - a PermissionError is spawned if the git executable provided - # cannot be executed for whatever reason - exceptions = (GitCommandNotFound, PermissionError) # noqa - # (silence erroneous flake8 F821) - + # - a GitCommandNotFound error is spawned by ourselves + # - a PermissionError is spawned if the git executable provided + # cannot be executed for whatever reason + has_git = False try: cls().version() has_git = True - except exceptions: + except (GitCommandNotFound, PermissionError): pass # warn or raise exception if test failed |