Skip to content

Commit 0ae0840

Browse files
davvidgitster
authored andcommitted
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 <[email protected]> Acked-by: Johan Herland <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0476228 commit 0ae0840

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1557,9 +1557,8 @@ $(patsubst %.py,%,$(SCRIPT_PYTHON)): % : %.py
15571557
-e '}' \
15581558
-e 's|^import sys.*|&; \\\
15591559
import os; \\\
1560-
sys.path[0] = os.environ.has_key("GITPYTHONLIB") and \\\
1561-
os.environ["GITPYTHONLIB"] or \\\
1562-
"@@INSTLIBDIR@@"|' \
1560+
sys.path.insert(0, os.getenv("GITPYTHONLIB",\
1561+
"@@INSTLIBDIR@@"));|' \
15631562
-e 's|@@INSTLIBDIR@@|'"$$INSTLIBDIR"'|g' \
15641563
$@.py >$@+ && \
15651564
chmod +x $@+ && \

0 commit comments

Comments
 (0)