Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Doc/library/compileall.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ compile Python sources.
file ...

Positional arguments are files to compile or directories that contain
source files, traversed recursively. If no argument is given, behave as if
the command line was :samp:`-l {<directories from sys.path>}`.
source files, traversed recursively. A named input path that does not exist
causes a nonzero exit status.
If no argument is given, behave as if the command line was
:samp:`-l {<directories from sys.path>}`.

.. option:: -l

Expand Down
4 changes: 4 additions & 0 deletions Lib/compileall.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,10 @@ def main():
limit_sl_dest=args.limit_sl_dest,
hardlink_dupes=args.hardlink_dupes):
success = False
elif dest and not os.path.exists(dest):
if args.quiet < 2:
print("Can't list {!r}".format(dest))
success = False
else:
if not compile_dir(dest, maxlevels, args.ddir,
args.force, args.rx, args.quiet,
Expand Down
17 changes: 16 additions & 1 deletion Lib/test/test_compileall.py
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,19 @@ def test_regexp(self):
self.assertNotCompiled(self.barfn)
self.assertCompiled(self.initfn)

def test_missing_dir(self):
missing = os.path.join(self.directory, 'missing')
rc, out, err = self.assertRunNotOK('-q', missing, self.pkgdir)
self.assertEqual(rc, 1)
self.assertIn(b"Can't list", out)
self.assertEqual(err, b'')
self.assertCompiled(self.barfn)

rc, out, err = self.assertRunNotOK('-qq', missing)
self.assertEqual(rc, 1)
self.assertEqual(out, b'')
self.assertEqual(err, b'')

def test_multiple_dirs(self):
pkgdir2 = os.path.join(self.directory, 'foo2')
os.mkdir(pkgdir2)
Expand Down Expand Up @@ -864,8 +877,10 @@ def test_compiles_as_much_as_possible(self):
self.assertCompiled(self.barfn)

def test_invalid_arg_produces_message(self):
out = self.assertRunOK('badfilename')
rc, out, err = self.assertRunNotOK('badfilename')
self.assertEqual(rc, 1)
self.assertRegex(out, b"Can't list 'badfilename'")
self.assertEqual(err, b'')

def test_pyc_invalidation_mode(self):
script_helper.make_script(self.pkgdir, 'f1', '')
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Make :mod:`compileall` exit with a nonzero status when an explicitly named
path does not exist.
Loading