mirror of
https://github.com/python/cpython.git
synced 2025-07-30 06:34:15 +00:00
#2225: return nonzero status code from py_compile if not all files could be compiled.
This commit is contained in:
parent
810ea29b0e
commit
a7bd27f0a8
3 changed files with 15 additions and 3 deletions
|
@ -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.
|
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
|
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::
|
.. seealso::
|
||||||
|
|
|
@ -154,11 +154,15 @@ def main(args=None):
|
||||||
"""
|
"""
|
||||||
if args is None:
|
if args is None:
|
||||||
args = sys.argv[1:]
|
args = sys.argv[1:]
|
||||||
|
rv = 0
|
||||||
for filename in args:
|
for filename in args:
|
||||||
try:
|
try:
|
||||||
compile(filename, doraise=True)
|
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)
|
sys.stderr.write(err.msg)
|
||||||
|
return rv
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
sys.exit(main())
|
||||||
|
|
|
@ -18,6 +18,9 @@ Core and builtins
|
||||||
Library
|
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
|
- Bug #1725737: In distutil's sdist, exclude RCS, CVS etc. also in the
|
||||||
root directory, and also exclude .hg, .git, .bzr, and _darcs.
|
root directory, and also exclude .hg, .git, .bzr, and _darcs.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue