mirror of
https://github.com/python/cpython.git
synced 2024-11-29 12:54:02 +08:00
3090694068
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.
45 lines
883 B
Python
45 lines
883 B
Python
# Test various flavors of legal and illegal future statements
|
|
|
|
from test_support import unload
|
|
import re
|
|
|
|
rx = re.compile('\((\S+).py, line (\d+)')
|
|
|
|
def check_error_location(msg):
|
|
mo = rx.search(msg)
|
|
print "SyntaxError %s %s" % mo.group(1, 2)
|
|
|
|
# The first two tests should work
|
|
|
|
unload('test_future1')
|
|
import test_future1
|
|
|
|
unload('test_future2')
|
|
import test_future2
|
|
|
|
# The remaining tests should fail
|
|
try:
|
|
import badsyntax_future3
|
|
except SyntaxError, msg:
|
|
check_error_location(str(msg))
|
|
|
|
try:
|
|
import badsyntax_future4
|
|
except SyntaxError, msg:
|
|
check_error_location(str(msg))
|
|
|
|
try:
|
|
import badsyntax_future5
|
|
except SyntaxError, msg:
|
|
check_error_location(str(msg))
|
|
|
|
try:
|
|
import badsyntax_future6
|
|
except SyntaxError, msg:
|
|
check_error_location(str(msg))
|
|
|
|
try:
|
|
import badsyntax_future7
|
|
except SyntaxError, msg:
|
|
check_error_location(str(msg))
|