[Python-checkins] cpython (3.2): Issue #11169: compileall module uses repr() to format filenames and paths to

victor.stinner python-checkins at python.org
Wed May 11 00:38:43 CEST 2011


http://hg.python.org/cpython/rev/85cfbbc7da60
changeset:   70026:85cfbbc7da60
branch:      3.2
parent:      70024:47236a0cfb15
user:        Victor Stinner <victor.stinner at haypocalc.com>
date:        Wed May 11 00:36:28 2011 +0200
summary:
  Issue #11169: compileall module uses repr() to format filenames and paths to
escape surrogate characters and show spaces.

files:
  Lib/compileall.py           |  10 +++++-----
  Lib/test/test_compileall.py |   2 +-
  Misc/NEWS                   |   3 +++
  3 files changed, 9 insertions(+), 6 deletions(-)


diff --git a/Lib/compileall.py b/Lib/compileall.py
--- a/Lib/compileall.py
+++ b/Lib/compileall.py
@@ -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)
diff --git a/Lib/test/test_compileall.py b/Lib/test/test_compileall.py
--- a/Lib/test/test_compileall.py
+++ b/Lib/test/test_compileall.py
@@ -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():
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -86,6 +86,9 @@
 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

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list