diff options
Diffstat (limited to 'pkgs/applications/science/math/sage/patches/python3-syntax-without-write.patch')
-rw-r--r-- | pkgs/applications/science/math/sage/patches/python3-syntax-without-write.patch | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/pkgs/applications/science/math/sage/patches/python3-syntax-without-write.patch b/pkgs/applications/science/math/sage/patches/python3-syntax-without-write.patch new file mode 100644 index 000000000000..ff1dcd22acf3 --- /dev/null +++ b/pkgs/applications/science/math/sage/patches/python3-syntax-without-write.patch @@ -0,0 +1,40 @@ +diff --git a/src/sage/tests/py3_syntax.py b/src/sage/tests/py3_syntax.py +index e564860b48..86ab3725f9 100644 +--- a/src/sage/tests/py3_syntax.py ++++ b/src/sage/tests/py3_syntax.py +@@ -179,15 +179,30 @@ class Python3SyntaxTest(SortedDirectoryWalkerABC): + sage: py3_syntax = Python3SyntaxTest() + sage: py3_syntax.test(src.name) + Invalid Python 3 syntax found: +- File "...py", line 1 +- print "invalid print statement" +- ^ +- SyntaxError: Missing parentheses in call to 'print' ++ Missing parentheses in call to 'print'... + sage: os.unlink(src.name) + """ ++ ++ # compile all given files in memory, printing all errors ++ # inspired by the py_compile module (but without writing to file) ++ script = """ ++import sys ++import importlib.machinery ++rv = 0 ++for file in sys.argv[1:]: ++ loader = importlib.machinery.SourceFileLoader('<sage_test>', file) ++ source_bytes = loader.get_data(file) ++ try: ++ code = loader.source_to_code(source_bytes, file) ++ except Exception as err: ++ print(err) ++ rv = 1 ++sys.exit(rv) ++""" + cmd = [ + 'python3', +- '-m', 'py_compile' ++ '-c', ++ script, + ] + list(filenames) + process = subprocess.Popen( + cmd, |