[Python-checkins] r88478 - in python/branches/py3k: Lib/compileall.py Lib/test/test_compileall.py Misc/NEWS

victor.stinner python-checkins at python.org
Mon Feb 21 21:58:02 CET 2011


Author: victor.stinner
Date: Mon Feb 21 21:58:02 2011
New Revision: 88478

Log:
compileall uses repr() to format filenames/paths

Issue #11169: compileall module uses repr() to format filenames and paths to
escape surrogate characters and show spaces.

Modified:
   python/branches/py3k/Lib/compileall.py
   python/branches/py3k/Lib/test/test_compileall.py
   python/branches/py3k/Misc/NEWS

Modified: python/branches/py3k/Lib/compileall.py
==============================================================================
--- python/branches/py3k/Lib/compileall.py	(original)
+++ python/branches/py3k/Lib/compileall.py	Mon Feb 21 21:58:02 2011
@@ -35,11 +35,11 @@
     optimize:  optimization level or -1 for level of the interpreter
     """
     if not quiet:
-        print('Listing', dir, '...')
+        print('Listing {!r}...'.format(dir))
     try:
         names = os.listdir(dir)
     except os.error:
-        print("Can't list", dir)
+        print("Can't list {!r}".format(dir))
         names = []
     names.sort()
     success = 1
@@ -109,13 +109,13 @@
                 except IOError:
                     pass
             if not quiet:
-                print('Compiling', fullname, '...')
+                print('Compiling {!r}...'.format(fullname))
             try:
                 ok = py_compile.compile(fullname, cfile, dfile, True,
                                         optimize=optimize)
             except py_compile.PyCompileError as err:
                 if quiet:
-                    print('*** Error compiling', fullname, '...')
+                    print('*** Error compiling {!r}...'.format(fullname))
                 else:
                     print('*** ', end='')
                 # escape non-printable characters in msg
@@ -126,7 +126,7 @@
                 success = 0
             except (SyntaxError, UnicodeError, IOError) as e:
                 if quiet:
-                    print('*** Error compiling', fullname, '...')
+                    print('*** Error compiling {!r}...'.format(fullname))
                 else:
                     print('*** ', end='')
                 print(e.__class__.__name__ + ':', e)

Modified: python/branches/py3k/Lib/test/test_compileall.py
==============================================================================
--- python/branches/py3k/Lib/test/test_compileall.py	(original)
+++ python/branches/py3k/Lib/test/test_compileall.py	Mon Feb 21 21:58:02 2011
@@ -345,7 +345,7 @@
 
     def test_invalid_arg_produces_message(self):
         out = self.assertRunOK('badfilename')
-        self.assertRegex(out, b"Can't list badfilename")
+        self.assertRegex(out, b"Can't list 'badfilename'")
 
 
 def test_main():

Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS	(original)
+++ python/branches/py3k/Misc/NEWS	Mon Feb 21 21:58:02 2011
@@ -19,6 +19,9 @@
 Library
 -------
 
+- Issue #11169: compileall module uses repr() to format filenames and paths to
+  escape surrogate characters and show spaces.
+
 - Issue #11089: Fix performance issue limiting the use of ConfigParser()
   with large config files.
 


More information about the Python-checkins mailing list