Merge: #19532: make compileall with no file/dir args respect -f and -q.
authorR David Murray <rdmurray@bitdance.com>
Mon, 16 Dec 2013 01:56:00 +0000 (20:56 -0500)
committerR David Murray <rdmurray@bitdance.com>
Mon, 16 Dec 2013 01:56:00 +0000 (20:56 -0500)
1  2 
Lib/compileall.py
Lib/test/test_compileall.py
Misc/NEWS

Simple merge
index ff2515df4cf137ecaf3a68e7a734191af0049f24,0505c521d1c4857b08ab7325ba05543730c9ada7..2a42238755c72e35aa171725a9b139f5498455ad
@@@ -5,8 -5,7 +5,6 @@@ import o
  import py_compile
  import shutil
  import struct
--import subprocess
- import sys
  import tempfile
  import time
  import unittest
@@@ -181,6 -177,29 +179,29 @@@ class CommandLineTests(unittest.TestCas
          self.assertNotCompiled(self.initfn)
          self.assertNotCompiled(self.barfn)
  
 -        pycpath = imp.cache_from_source(bazfn)
+     def test_no_args_respects_force_flag(self):
+         bazfn = script_helper.make_script(self.directory, 'baz', '')
+         self.assertRunOK(PYTHONPATH=self.directory)
++        pycpath = importlib.util.cache_from_source(bazfn)
+         # Set atime/mtime backward to avoid file timestamp resolution issues
+         os.utime(pycpath, (time.time()-60,)*2)
+         mtime = os.stat(pycpath).st_mtime
+         # Without force, no recompilation
+         self.assertRunOK(PYTHONPATH=self.directory)
+         mtime2 = os.stat(pycpath).st_mtime
+         self.assertEqual(mtime, mtime2)
+         # Now force it.
+         self.assertRunOK('-f', PYTHONPATH=self.directory)
+         mtime2 = os.stat(pycpath).st_mtime
+         self.assertNotEqual(mtime, mtime2)
+     def test_no_args_respects_quiet_flag(self):
+         script_helper.make_script(self.directory, 'baz', '')
+         noisy = self.assertRunOK(PYTHONPATH=self.directory)
+         self.assertIn(b'Listing ', noisy)
+         quiet = self.assertRunOK('-q', PYTHONPATH=self.directory)
+         self.assertNotIn(b'Listing ', quiet)
      # Ensure that the default behavior of compileall's CLI is to create
      # PEP 3147 pyc/pyo files.
      for name, ext, switch in [
diff --cc Misc/NEWS
index e1a5c5469a7f79b545ddb8f1025018a24fac5f26,73625f3a5a740f0de81692ff340ddc166ea3dd16..3819d6cb7a720ec8928beb43ec7551abb8e29bc7
+++ b/Misc/NEWS
@@@ -44,11 -29,11 +44,14 @@@ Core and Builtin
  Library
  -------
  
+ - Issue #19532: python -m compileall with no filename/directory arguments now
+   respects the -f and -q flags instead of ignoring them.
  - Issue #19623: Fixed writing to unseekable files in the aifc module.
  
 +- Issue #19946: multiprocessing.spawn now raises ImportError when the module to
 +  be used as the main module cannot be imported.
 +
  - Issue #17919: select.poll.register() again works with poll.POLLNVAL on AIX.
    Fixed integer overflow in the eventmask parameter.