churchyard / rpms / python3

Forked from rpms/python3 6 years ago
Clone

Blame 00186-dont-raise-from-py_compile.patch

3dbbc14
diff -r 7fa3e824a4ee Lib/py_compile.py
3dbbc14
--- a/Lib/py_compile.py	Tue Oct 29 22:25:06 2013 -0400
3dbbc14
+++ b/Lib/py_compile.py	Wed Oct 30 11:08:31 2013 +0100
3dbbc14
@@ -108,15 +108,15 @@
3dbbc14
     byte-compile all installed files (or all files in selected
3dbbc14
     directories).
3dbbc14
     """
3dbbc14
-    with tokenize.open(file) as f:
3dbbc14
-        try:
3dbbc14
-            st = os.fstat(f.fileno())
3dbbc14
-        except AttributeError:
3dbbc14
-            st = os.stat(file)
3dbbc14
-        timestamp = int(st.st_mtime)
3dbbc14
-        size = st.st_size & 0xFFFFFFFF
3dbbc14
-        codestring = f.read()
3dbbc14
     try:
3dbbc14
+        with tokenize.open(file) as f:
3dbbc14
+            try:
3dbbc14
+                st = os.fstat(f.fileno())
3dbbc14
+            except AttributeError:
3dbbc14
+                st = os.stat(file)
3dbbc14
+            timestamp = int(st.st_mtime)
3dbbc14
+            size = st.st_size & 0xFFFFFFFF
3dbbc14
+            codestring = f.read()
3dbbc14
         codeobject = builtins.compile(codestring, dfile or file, 'exec',
3dbbc14
                                       optimize=optimize)
3dbbc14
     except Exception as err:
3dbbc14
diff -r 7fa3e824a4ee Lib/test/test_py_compile.py
3dbbc14
--- a/Lib/test/test_py_compile.py	Tue Oct 29 22:25:06 2013 -0400
3dbbc14
+++ b/Lib/test/test_py_compile.py	Wed Oct 30 11:08:31 2013 +0100
3dbbc14
@@ -54,6 +54,10 @@
3dbbc14
         self.assertTrue(os.path.exists(self.pyc_path))
3dbbc14
         self.assertFalse(os.path.exists(self.cache_path))
3dbbc14
 
3dbbc14
+    def test_bad_coding(self):
3dbbc14
+        bad_coding = os.path.join(os.path.dirname(__file__), 'bad_coding2.py')
3dbbc14
+        self.assertIsNone(py_compile.compile(bad_coding, doraise=False))
3dbbc14
+
3dbbc14
 def test_main():
3dbbc14
     support.run_unittest(PyCompileTests)
3dbbc14