summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2008-03-06 07:41:16 +0000
committerGeorg Brandl <georg@python.org>2008-03-06 07:41:16 +0000
commita7bd27f0a8dd7acbf0098f50d28ed9783fdce605 (patch)
tree4968123959c62ef2f90daae5e377858d919acb3f
parent810ea29b0ea0369be6fb401f27863be03c4c4690 (diff)
downloadcpython-git-a7bd27f0a8dd7acbf0098f50d28ed9783fdce605.tar.gz
#2225: return nonzero status code from py_compile if not all files could be compiled.
-rw-r--r--Doc/library/py_compile.rst7
-rw-r--r--Lib/py_compile.py8
-rw-r--r--Misc/NEWS3
3 files changed, 15 insertions, 3 deletions
diff --git a/Doc/library/py_compile.rst b/Doc/library/py_compile.rst
index de9a80e2a6..77ed8cf4a0 100644
--- a/Doc/library/py_compile.rst
+++ b/Doc/library/py_compile.rst
@@ -42,7 +42,12 @@ byte-code cache files in the directory containing the source code.
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::
diff --git a/Lib/py_compile.py b/Lib/py_compile.py
index 1cb41f1e0e..89e80f8e6f 100644
--- a/Lib/py_compile.py
+++ b/Lib/py_compile.py
@@ -154,11 +154,15 @@ def main(args=None):
"""
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())
diff --git a/Misc/NEWS b/Misc/NEWS
index 15f7f10867..42b95e8b29 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -18,6 +18,9 @@ Core and builtins
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.