diff --git a/docs/scripts/ns-html2rst b/docs/scripts/ns-html2rst
index 004cf6f6d6a29..96e25e9eb691d 100755
--- a/docs/scripts/ns-html2rst
+++ b/docs/scripts/ns-html2rst
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
import sys, re, subprocess
def run():
diff --git a/test/Driver/Dependencies/Inputs/fake-build-for-bitcode.py b/test/Driver/Dependencies/Inputs/fake-build-for-bitcode.py
index 24855b144601b..38e0a01336c8a 100755
--- a/test/Driver/Dependencies/Inputs/fake-build-for-bitcode.py
+++ b/test/Driver/Dependencies/Inputs/fake-build-for-bitcode.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
# Emulates the frontend of an -embed-bitcode job. That means we have to handle
# -emit-bc and -c actions.
diff --git a/test/Driver/Dependencies/Inputs/fake-build-whole-module.py b/test/Driver/Dependencies/Inputs/fake-build-whole-module.py
index 3b176a2846ee4..5484cb1455ed1 100755
--- a/test/Driver/Dependencies/Inputs/fake-build-whole-module.py
+++ b/test/Driver/Dependencies/Inputs/fake-build-whole-module.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
# Emulates the frontend of a -whole-module-optimization compilation.
diff --git a/test/Driver/Dependencies/Inputs/modify-non-primary-files.py b/test/Driver/Dependencies/Inputs/modify-non-primary-files.py
index a131a72067f43..3553bebf0b971 100755
--- a/test/Driver/Dependencies/Inputs/modify-non-primary-files.py
+++ b/test/Driver/Dependencies/Inputs/modify-non-primary-files.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
# modify-non-primary-files.py simulates a build where the user is modifying the
# source files during compilation.
diff --git a/test/Driver/Dependencies/Inputs/update-dependencies-bad.py b/test/Driver/Dependencies/Inputs/update-dependencies-bad.py
index 1c2c9f8d98f5e..0211f71b49550 100755
--- a/test/Driver/Dependencies/Inputs/update-dependencies-bad.py
+++ b/test/Driver/Dependencies/Inputs/update-dependencies-bad.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
# Fails if the input file is named "bad.swift"; otherwise dispatches to
# update-dependencies.py.
@@ -12,7 +12,7 @@
if os.path.basename(primaryFile) == 'bad.swift':
print "Handled", os.path.basename(primaryFile)
- exit(1)
+ sys.exit(1)
dir = os.path.dirname(os.path.abspath(__file__))
execfile(os.path.join(dir, "update-dependencies.py"))
diff --git a/test/Driver/Dependencies/Inputs/update-dependencies.py b/test/Driver/Dependencies/Inputs/update-dependencies.py
index aac77698ff47c..504eaf5cb8d06 100755
--- a/test/Driver/Dependencies/Inputs/update-dependencies.py
+++ b/test/Driver/Dependencies/Inputs/update-dependencies.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
# update-dependencies.py simulates a Swift compilation for the purposes of
# dependency analysis. That means it has two tasks:
diff --git a/test/Inputs/getmtime.py b/test/Inputs/getmtime.py
index 0a7a1397b6a8b..f0c27b444125d 100755
--- a/test/Inputs/getmtime.py
+++ b/test/Inputs/getmtime.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
import os
import sys
diff --git a/utils/apply-fixit-edits.py b/utils/apply-fixit-edits.py
index 674ee7745c0e1..1d7289315acf4 100755
--- a/utils/apply-fixit-edits.py
+++ b/utils/apply-fixit-edits.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
#===--- apply-fixit-edits.py - Tool for applying edits from .remap files ---===#
#
diff --git a/utils/demo-tool b/utils/demo-tool
index 31b553ba7553a..9b0100312980e 100755
--- a/utils/demo-tool
+++ b/utils/demo-tool
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
import json
import optparse
diff --git a/utils/gyb.py b/utils/gyb.py
index f0533fa568991..af9c3d3836d10 100755
--- a/utils/gyb.py
+++ b/utils/gyb.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
# GYB: Generate Your Boilerplate (improved names welcome; at least
# this one's short). See -h output for instructions
diff --git a/utils/pre-commit-benchmark b/utils/pre-commit-benchmark
index b87df62362452..fd246434cb793 100755
--- a/utils/pre-commit-benchmark
+++ b/utils/pre-commit-benchmark
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
# Note: it doesn't matter what directory you invoke this in; it uses
# your SWIFT_BUILD_ROOT and SWIFT_SOURCE_ROOT settings, just like
diff --git a/utils/recursive-lipo b/utils/recursive-lipo
index e2a4a3cac3a9d..4183bfd7d42b0 100755
--- a/utils/recursive-lipo
+++ b/utils/recursive-lipo
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
import argparse
import os.path
diff --git a/utils/submit-benchmark-results b/utils/submit-benchmark-results
index 45d7218907ab1..4cb07d05b26cc 100755
--- a/utils/submit-benchmark-results
+++ b/utils/submit-benchmark-results
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
"""
Utility script for submitting benchmark results to an LNT server.
diff --git a/utils/viewcfg b/utils/viewcfg
index 9935da52d900f..3356831fb8628 100755
--- a/utils/viewcfg
+++ b/utils/viewcfg
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
# A script for viewing the CFG of SIL and llvm IR.