Index: Lib/compileall.py =================================================================== --- Lib/compileall.py (revision 87048) +++ Lib/compileall.py (working copy) @@ -181,11 +181,12 @@ 'of the file')) parser.add_argument('-i', metavar='FILE', dest='flist', help='expand the list with the content of FILE.') - parser.add_argument('compile_dest', metavar='FILE|DIR', nargs='?') + parser.add_argument('compile_dest', metavar='FILE|DIR', nargs='*') args = parser.parse_args() - if (args.ddir and args.compile_dest != 1 and - not os.path.isdir(args.compile_dest)): + compile_dests = args.compile_dest + + if args.ddir and len(compile_dests) != 1: raise argparse.ArgumentError( "-d destdir requires exactly one directory argument") if args.rx: @@ -193,7 +194,6 @@ args.rx = re.compile(args.rx) # if flist is provided then load it - compile_dests = [args.compile_dest] if args.flist: with open(args.flist) as f: files = f.read().split() Index: Lib/test/test_compileall.py =================================================================== --- Lib/test/test_compileall.py (revision 87048) +++ Lib/test/test_compileall.py (working copy) @@ -247,6 +247,17 @@ sourcefile = os.path.join(self.pkgdir, '__init__.py') self.assertTrue(os.path.exists(imp.cache_from_source(sourcefile))) + def test_multiple_dirs(self): + pkgdir2 = os.path.join(self.directory, 'foo2') + os.mkdir(pkgdir2) + open(os.path.join(pkgdir2, '__init__.py'), 'w').close() + open(os.path.join(pkgdir2, 'bar2.py'), 'w').close() + retcode = subprocess.call( + (sys.executable, '-m', 'compileall', '-q', self.pkgdir, pkgdir2)) + self.assertEqual(retcode, 0) + self.assertTrue(os.path.exists(os.path.join(self.pkgdir, '__pycache__'))) + self.assertTrue(os.path.exists(os.path.join(pkgdir2, '__pycache__'))) + def test_main(): support.run_unittest(