[Python-checkins] r61273 - in python/trunk: Doc/library/py_compile.rst Lib/py_compile.py Misc/NEWS

georg.brandl python-checkins at python.org
Thu Mar 6 08:41:17 CET 2008


Author: georg.brandl
Date: Thu Mar  6 08:41:16 2008
New Revision: 61273

Modified:
   python/trunk/Doc/library/py_compile.rst
   python/trunk/Lib/py_compile.py
   python/trunk/Misc/NEWS
Log:
#2225: return nonzero status code from py_compile if not all files could be compiled.


Modified: python/trunk/Doc/library/py_compile.rst
==============================================================================
--- python/trunk/Doc/library/py_compile.rst	(original)
+++ python/trunk/Doc/library/py_compile.rst	Thu Mar  6 08:41:16 2008
@@ -42,7 +42,12 @@
    structure to locate source files; it only compiles files named explicitly.
 
 When this module is run as a script, the :func:`main` is used to compile all the
-files named on the command line.
+files named on the command line.  The exit status is nonzero if one of the files
+could not be compiled.
+
+.. versionchanged:: 2.6
+
+   Added the nonzero exit status.
 
 
 .. seealso::

Modified: python/trunk/Lib/py_compile.py
==============================================================================
--- python/trunk/Lib/py_compile.py	(original)
+++ python/trunk/Lib/py_compile.py	Thu Mar  6 08:41:16 2008
@@ -154,11 +154,15 @@
     """
     if args is None:
         args = sys.argv[1:]
+    rv = 0
     for filename in args:
         try:
             compile(filename, doraise=True)
-        except PyCompileError,err:
+        except PyCompileError, err:
+            # return value to indicate at least one failure
+            rv = 1
             sys.stderr.write(err.msg)
+    return rv
 
 if __name__ == "__main__":
-    main()
+    sys.exit(main())

Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS	(original)
+++ python/trunk/Misc/NEWS	Thu Mar  6 08:41:16 2008
@@ -18,6 +18,9 @@
 Library
 -------
 
+- Issue #2225: py_compile, when executed as a script, now returns a non-
+  zero status code if not all files could be compiled successfully.
+
 - Bug #1725737: In distutil's sdist, exclude RCS, CVS etc. also in the
   root directory, and also exclude .hg, .git, .bzr, and _darcs.
 


More information about the Python-checkins mailing list