From 3090694068670371cdbd5b1a3d3c5dbecc83835a Mon Sep 17 00:00:00 2001
From: Jeremy Hylton <jeremy@alum.mit.edu>
Date: Wed, 18 Apr 2001 01:19:28 +0000
Subject: Fix compileall.py so that it fails on SyntaxErrors

The changes cause compilation failures in any file in the Python
installation lib directory to cause the install to fail.  It looks
like compileall.py intended to behave this way, but a change to
py_compile.py and a separate bug defeated it.

Fixes SF bug #412436

This change affects the test suite, which contains several files that
contain intentional errors.  The solution is to extend compileall.py
with the ability to skip compilation of selected files.

In the test suite, rename nocaret.py and test_future[3..7].py to start
with badsyntax_nocaret.py and badsyntax_future[3..7].py.  Update the
makefile to skip compilation of these files.  Update the tests to use
the name names for imports.

NB compileall.py is changed so that compile_dir() returns success only
if all recursive calls to compile_dir() also check success.
---
 Lib/test/badsyntax_future3.py | 10 ++++++++++
 Lib/test/badsyntax_future4.py | 10 ++++++++++
 Lib/test/badsyntax_future5.py | 12 ++++++++++++
 Lib/test/badsyntax_future6.py | 10 ++++++++++
 Lib/test/badsyntax_future7.py | 11 +++++++++++
 Lib/test/badsyntax_nocaret.py |  2 ++
 Lib/test/nocaret.py           |  2 --
 Lib/test/output/test_future   | 10 +++++-----
 Lib/test/regrtest.py          |  5 -----
 Lib/test/test_future.py       | 10 +++++-----
 Lib/test/test_future3.py      | 10 ----------
 Lib/test/test_future4.py      | 10 ----------
 Lib/test/test_future5.py      | 12 ------------
 Lib/test/test_future6.py      | 10 ----------
 Lib/test/test_future7.py      | 11 -----------
 Lib/test/test_traceback.py    |  2 +-
 16 files changed, 66 insertions(+), 71 deletions(-)
 create mode 100644 Lib/test/badsyntax_future3.py
 create mode 100644 Lib/test/badsyntax_future4.py
 create mode 100644 Lib/test/badsyntax_future5.py
 create mode 100644 Lib/test/badsyntax_future6.py
 create mode 100644 Lib/test/badsyntax_future7.py
 create mode 100644 Lib/test/badsyntax_nocaret.py
 delete mode 100644 Lib/test/nocaret.py
 delete mode 100644 Lib/test/test_future3.py
 delete mode 100644 Lib/test/test_future4.py
 delete mode 100644 Lib/test/test_future5.py
 delete mode 100644 Lib/test/test_future6.py
 delete mode 100644 Lib/test/test_future7.py

diff --git a/Lib/test/badsyntax_future3.py b/Lib/test/badsyntax_future3.py
new file mode 100644
index 0000000..166628c
--- /dev/null
+++ b/Lib/test/badsyntax_future3.py
@@ -0,0 +1,10 @@
+"""This is a test"""
+from __future__ import nested_scopes
+from __future__ import rested_snopes
+
+def f(x):
+    def g(y):
+        return x + y
+    return g
+
+print f(2)(4)
diff --git a/Lib/test/badsyntax_future4.py b/Lib/test/badsyntax_future4.py
new file mode 100644
index 0000000..805263b
--- /dev/null
+++ b/Lib/test/badsyntax_future4.py
@@ -0,0 +1,10 @@
+"""This is a test"""
+import __future__
+from __future__ import nested_scopes
+
+def f(x):
+    def g(y):
+        return x + y
+    return g
+
+print f(2)(4)
diff --git a/Lib/test/badsyntax_future5.py b/Lib/test/badsyntax_future5.py
new file mode 100644
index 0000000..1186208
--- /dev/null
+++ b/Lib/test/badsyntax_future5.py
@@ -0,0 +1,12 @@
+"""This is a test"""
+from __future__ import nested_scopes
+import foo
+from __future__ import nested_scopes
+
+
+def f(x):
+    def g(y):
+        return x + y
+    return g
+
+print f(2)(4)
diff --git a/Lib/test/badsyntax_future6.py b/Lib/test/badsyntax_future6.py
new file mode 100644
index 0000000..35c1455
--- /dev/null
+++ b/Lib/test/badsyntax_future6.py
@@ -0,0 +1,10 @@
+"""This is a test"""
+"this isn't a doc string"
+from __future__ import nested_scopes
+
+def f(x):
+    def g(y):
+        return x + y
+    return g
+
+print f(2)(4)
diff --git a/Lib/test/badsyntax_future7.py b/Lib/test/badsyntax_future7.py
new file mode 100644
index 0000000..370372d
--- /dev/null
+++ b/Lib/test/badsyntax_future7.py
@@ -0,0 +1,11 @@
+"""This is a test"""
+
+from __future__ import nested_scopes; import string; from __future__ import \
+     nested_scopes
+
+def f(x):
+    def g(y):
+        return x + y
+    return g
+
+print f(2)(4)
diff --git a/Lib/test/badsyntax_nocaret.py b/Lib/test/badsyntax_nocaret.py
new file mode 100644
index 0000000..01ec9ea
--- /dev/null
+++ b/Lib/test/badsyntax_nocaret.py
@@ -0,0 +1,2 @@
+def f(x):
+    [x for x in x] = x
diff --git a/Lib/test/nocaret.py b/Lib/test/nocaret.py
deleted file mode 100644
index 01ec9ea..0000000
--- a/Lib/test/nocaret.py
+++ /dev/null
@@ -1,2 +0,0 @@
-def f(x):
-    [x for x in x] = x
diff --git a/Lib/test/output/test_future b/Lib/test/output/test_future
index 5d7770a..4631489 100644
--- a/Lib/test/output/test_future
+++ b/Lib/test/output/test_future
@@ -1,8 +1,8 @@
 test_future
 6
 6
-SyntaxError test_future3 3
-SyntaxError test_future4 3
-SyntaxError test_future5 4
-SyntaxError test_future6 3
-SyntaxError test_future7 3
+SyntaxError badsyntax_future3 3
+SyntaxError badsyntax_future4 3
+SyntaxError badsyntax_future5 4
+SyntaxError badsyntax_future6 3
+SyntaxError badsyntax_future7 3
diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py
index f05f764..ffa67f1 100755
--- a/Lib/test/regrtest.py
+++ b/Lib/test/regrtest.py
@@ -199,11 +199,6 @@ NOTTESTS = [
     'test_b2',
     'test_future1',
     'test_future2',
-    'test_future3',
-    'test_future4',
-    'test_future5',
-    'test_future6',
-    'test_future7',
     ]
 
 def findtests(testdir=None, stdtests=STDTESTS, nottests=NOTTESTS):
diff --git a/Lib/test/test_future.py b/Lib/test/test_future.py
index 1ffda5e..ba0763b 100644
--- a/Lib/test/test_future.py
+++ b/Lib/test/test_future.py
@@ -19,26 +19,26 @@ import test_future2
 
 # The remaining tests should fail
 try:
-    import test_future3
+    import badsyntax_future3
 except SyntaxError, msg:
     check_error_location(str(msg))
 
 try:
-    import test_future4
+    import badsyntax_future4
 except SyntaxError, msg:
     check_error_location(str(msg))
 
 try:
-    import test_future5
+    import badsyntax_future5
 except SyntaxError, msg:
     check_error_location(str(msg))
 
 try:
-    import test_future6
+    import badsyntax_future6
 except SyntaxError, msg:
     check_error_location(str(msg))
 
 try:
-    import test_future7
+    import badsyntax_future7
 except SyntaxError, msg:
     check_error_location(str(msg))
diff --git a/Lib/test/test_future3.py b/Lib/test/test_future3.py
deleted file mode 100644
index 166628c..0000000
--- a/Lib/test/test_future3.py
+++ /dev/null
@@ -1,10 +0,0 @@
-"""This is a test"""
-from __future__ import nested_scopes
-from __future__ import rested_snopes
-
-def f(x):
-    def g(y):
-        return x + y
-    return g
-
-print f(2)(4)
diff --git a/Lib/test/test_future4.py b/Lib/test/test_future4.py
deleted file mode 100644
index 805263b..0000000
--- a/Lib/test/test_future4.py
+++ /dev/null
@@ -1,10 +0,0 @@
-"""This is a test"""
-import __future__
-from __future__ import nested_scopes
-
-def f(x):
-    def g(y):
-        return x + y
-    return g
-
-print f(2)(4)
diff --git a/Lib/test/test_future5.py b/Lib/test/test_future5.py
deleted file mode 100644
index 1186208..0000000
--- a/Lib/test/test_future5.py
+++ /dev/null
@@ -1,12 +0,0 @@
-"""This is a test"""
-from __future__ import nested_scopes
-import foo
-from __future__ import nested_scopes
-
-
-def f(x):
-    def g(y):
-        return x + y
-    return g
-
-print f(2)(4)
diff --git a/Lib/test/test_future6.py b/Lib/test/test_future6.py
deleted file mode 100644
index 35c1455..0000000
--- a/Lib/test/test_future6.py
+++ /dev/null
@@ -1,10 +0,0 @@
-"""This is a test"""
-"this isn't a doc string"
-from __future__ import nested_scopes
-
-def f(x):
-    def g(y):
-        return x + y
-    return g
-
-print f(2)(4)
diff --git a/Lib/test/test_future7.py b/Lib/test/test_future7.py
deleted file mode 100644
index 370372d..0000000
--- a/Lib/test/test_future7.py
+++ /dev/null
@@ -1,11 +0,0 @@
-"""This is a test"""
-
-from __future__ import nested_scopes; import string; from __future__ import \
-     nested_scopes
-
-def f(x):
-    def g(y):
-        return x + y
-    return g
-
-print f(2)(4)
diff --git a/Lib/test/test_traceback.py b/Lib/test/test_traceback.py
index 759cc98..9f818e1 100644
--- a/Lib/test/test_traceback.py
+++ b/Lib/test/test_traceback.py
@@ -22,7 +22,7 @@ class TracebackCases(unittest.TestCase):
 
     def syntax_error_without_caret(self):
         # XXX why doesn't compile raise the same traceback?
-        import nocaret
+        import badsyntax_nocaret
 
     def test_caret(self):
         err = self.get_exception_format(self.syntax_error_with_caret,
-- 
cgit v0.12

