]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #11169: compileall module uses repr() to format filenames and paths to
authorVictor Stinner <victor.stinner@haypocalc.com>
Tue, 10 May 2011 22:36:28 +0000 (00:36 +0200)
committerVictor Stinner <victor.stinner@haypocalc.com>
Tue, 10 May 2011 22:36:28 +0000 (00:36 +0200)
escape surrogate characters and show spaces.

Lib/compileall.py
Lib/test/test_compileall.py
Misc/NEWS

index d79a1bb9a092c40892eb7a97fa62ebe36abff527..743be2766412c29f63ca84aefa71e6fc25864723 100644 (file)
@@ -35,11 +35,11 @@ def compile_dir(dir, maxlevels=10, ddir=None, force=False, rx=None,
     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 @@ def compile_file(fullname, ddir=None, force=False, rx=None, quiet=False,
                 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 @@ def compile_file(fullname, ddir=None, force=False, rx=None, quiet=False,
                 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)
index c1dfdb376f2f722f7ca1c550bace1c0a743c39d1..d1c9ee58bd4fad57112d98864fb34694cc6bb882 100644 (file)
@@ -345,7 +345,7 @@ class CommandLineTests(unittest.TestCase):
 
     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():
index 0307c801ea4d34183aa1f6aa9d7545158c84a90f..7fa8ed7c8ff42f66067a492219b85e5af09753ea 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -86,6 +86,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #11169: compileall module uses repr() to format filenames and paths to
+  escape surrogate characters and show spaces.
+
 - Issue #10419, #6011: build_scripts command of distutils handles correctly
   non-ASCII path (path to the Python executable). Open and write the script in
   binary mode, but ensure that the shebang is decodable from UTF-8 and from the