churchyard / rpms / python3

Forked from rpms/python3 6 years ago
Clone

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

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