-
-
Notifications
You must be signed in to change notification settings - Fork 933
Fails on import with custom exception #637
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
(this was using version 2.1.5) |
It seems like this was introduced in 2.1.4 (2.1.3 imports flawlessly even without git on path). |
Wow, I was literally just about to make this ticket. At the moment my only option to conditionally import is something like: try:
import git
except:
pass But as @vidartf notes, that's less than ideal. |
Thanks for reporting this issue! I believe that the problem originates here, and could be solved by delaying that particular operation until that Personally I believe at the time of import, nothing but ImportErrors should be thrown, which is clearly violated here. |
A possible solution is that of #640 where The above mentioned PR introduces a |
See the following issue which explains why we can't catch a specific exception type: gitpython-developers/GitPython#637
See the following issue which explains why we can't catch a specific exception type: gitpython-developers/GitPython#637
See the following issue which explains why we can't catch a specific exception type: gitpython-developers/GitPython#637
This should be fixed with the latest, upcoming release, |
On Windows, without git available on path, the following happens on import of GitPython:
Since it fails while trying to import the exception type that it raises (
GitError
), the only way to catch the error is with atry: ... except Exception:
block, which is needlessly wide. It would be nice if a better pattern was available for conditional use of the package.The text was updated successfully, but these errors were encountered: