From: David Aguilar Date: Sun, 28 Mar 2010 00:45:12 +0000 (-0700) Subject: Makefile: Remove usage of deprecated Python "has_key" method X-Git-Tag: v1.7.1-rc0~1^2 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=0ae08401beb0daef9946b6fe25224a4cf167c655;p=git.git Makefile: Remove usage of deprecated Python "has_key" method "has_key" is a deprecated dictionary method in Python 2.6+. Simplify the sys.path manipulation for installed scripts by passing a default value to os.getenv() that takes a default value to be used when the environment variable is missing. SCRIPT_PYTHON is currently empty but this future-proofs us. It also fixes things for users who maintain local git forks with their own SCRIPT_PYTHON additions. Old code replaced the first element of sys.path[] which is typically '' (i.e. import library files relative to the script). It is safer to prepend the extra library path instead. Signed-off-by: David Aguilar Acked-by: Johan Herland Signed-off-by: Junio C Hamano --- diff --git a/Makefile b/Makefile index 98372ebbf..2f55649b6 100644 --- a/Makefile +++ b/Makefile @@ -1557,9 +1557,8 @@ $(patsubst %.py,%,$(SCRIPT_PYTHON)): % : %.py -e '}' \ -e 's|^import sys.*|&; \\\ import os; \\\ - sys.path[0] = os.environ.has_key("GITPYTHONLIB") and \\\ - os.environ["GITPYTHONLIB"] or \\\ - "@@INSTLIBDIR@@"|' \ + sys.path.insert(0, os.getenv("GITPYTHONLIB",\ + "@@INSTLIBDIR@@"));|' \ -e 's|@@INSTLIBDIR@@|'"$$INSTLIBDIR"'|g' \ $@.py >$@+ && \ chmod +x $@+ && \