Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f217e21

Browse files
committed
Tweaked 'byte_compile()' so it silently skips non-Python files, rather than
blowing up.
1 parent 4b6ea79 commit f217e21

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

Lib/distutils/util.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -297,9 +297,10 @@ def byte_compile (py_files,
297297
prefix=None, base_dir=None,
298298
verbose=1, dry_run=0,
299299
direct=None):
300-
"""Byte-compile a collection of Python source files to either
301-
.pyc or .pyo files in the same directory. 'optimize' must be
302-
one of the following:
300+
"""Byte-compile a collection of Python source files to either .pyc
301+
or .pyo files in the same directory. 'py_files' is a list of files
302+
to compile; any files that don't end in ".py" are silently skipped.
303+
'optimize' must be one of the following:
303304
0 - don't optimize (generate .pyc)
304305
1 - normal optimization (like "python -O")
305306
2 - extra optimization (like "python -OO")
@@ -378,8 +379,9 @@ def byte_compile (py_files,
378379

379380
for file in py_files:
380381
if file[-3:] != ".py":
381-
raise ValueError, \
382-
"invalid filename: %s doesn't end with '.py'" % `file`
382+
# This lets us be lazy and not filter filenames in
383+
# the "install_lib" command.
384+
continue
383385

384386
# Terminology from the py_compile module:
385387
# cfile - byte-compiled file

0 commit comments

Comments
 (0)