From b285d777f3d26b073a40a7548a1988408c1eb34a Mon Sep 17 00:00:00 2001 From: heinrich5991 Date: Fri, 2 Mar 2018 03:22:44 +0100 Subject: [PATCH] Python 2 support for `scripts/git_revision.py` on error /o\ --- scripts/git_revision.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/scripts/git_revision.py b/scripts/git_revision.py index f87394393..e40a2cdc4 100644 --- a/scripts/git_revision.py +++ b/scripts/git_revision.py @@ -1,7 +1,16 @@ +import errno import subprocess +try: + FileNotFoundError +except NameError: + FileNotFoundError = OSError try: git_hash = subprocess.check_output(["git", "rev-parse", "--short=16", "HEAD"], stderr=None).decode().strip() definition = '"{}"'.format(git_hash) -except (FileNotFoundError, subprocess.CalledProcessError): +except FileNotFoundError as e: + if e.errno != errno.ENOENT: + raise + definition = "0" +except subprocess.CalledProcessError: definition = "0"; print("const char *GIT_SHORTREV_HASH = {};".format(definition))