Content-Length: 2101 | pFad | http://github.com/gitpython-developers/GitPython/pull/830.patch

thub.com From 5cb36d84f677a7e648259176220a3340f8575214 Mon Sep 17 00:00:00 2001 From: cclauss Date: Mon, 21 Jan 2019 12:13:56 +0100 Subject: [PATCH] Update cmd.py Simplify by defining [__PermissionError__](https://docs.python.org/3/library/exceptions.html#PermissionError) in Python 2 in alignment with Python porting best practice [___use feature detection instead of version detection___](https://docs.python.org/3/howto/pyporting.html#use-feature-detection-instead-of-version-detection). --- git/cmd.py | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/git/cmd.py b/git/cmd.py index a4faefe23..e442095e4 100644 --- a/git/cmd.py +++ b/git/cmd.py @@ -43,6 +43,10 @@ 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,22 +215,15 @@ def refresh(cls, path=None): # 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) - + # - 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








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/gitpython-developers/GitPython/pull/830.patch

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy