diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-02-21 20:58:02 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-02-21 20:58:02 (GMT) |
commit | 441cc01e0f172599d544a18a3fe8ad08a9dd633a (patch) | |
tree | 79e624e8e3cf21883c6d9f9e88b7ef84275a64a8 | |
parent | fd34b3788fbfb1e46ece705e1df49ac6ac1e8b84 (diff) | |
download | cpython-441cc01e0f172599d544a18a3fe8ad08a9dd633a.zip cpython-441cc01e0f172599d544a18a3fe8ad08a9dd633a.tar.gz cpython-441cc01e0f172599d544a18a3fe8ad08a9dd633a.tar.bz2 |
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.
-rw-r--r-- | Lib/compileall.py | 10 | ||||
-rw-r--r-- | Lib/test/test_compileall.py | 2 | ||||
-rw-r--r-- | Misc/NEWS | 3 |
3 files changed, 9 insertions, 6 deletions
diff --git a/Lib/compileall.py b/Lib/compileall.py index d79a1bb..743be27 100644 --- a/Lib/compileall.py +++ b/Lib/compileall.py @@ -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) diff --git a/Lib/test/test_compileall.py b/Lib/test/test_compileall.py index 250d31b..a63af4c 100644 --- a/Lib/test/test_compileall.py +++ b/Lib/test/test_compileall.py @@ -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(): @@ -19,6 +19,9 @@ Core and Builtins 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. |