mirror of https://github.com/python/cpython
Issue #11169: compileall module uses repr() to format filenames and paths to
escape surrogate characters and show spaces.
This commit is contained in:
parent
1eb4f28c6d
commit
530712625b
|
@ -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
|
optimize: optimization level or -1 for level of the interpreter
|
||||||
"""
|
"""
|
||||||
if not quiet:
|
if not quiet:
|
||||||
print('Listing', dir, '...')
|
print('Listing {!r}...'.format(dir))
|
||||||
try:
|
try:
|
||||||
names = os.listdir(dir)
|
names = os.listdir(dir)
|
||||||
except os.error:
|
except os.error:
|
||||||
print("Can't list", dir)
|
print("Can't list {!r}".format(dir))
|
||||||
names = []
|
names = []
|
||||||
names.sort()
|
names.sort()
|
||||||
success = 1
|
success = 1
|
||||||
|
@ -109,13 +109,13 @@ def compile_file(fullname, ddir=None, force=False, rx=None, quiet=False,
|
||||||
except IOError:
|
except IOError:
|
||||||
pass
|
pass
|
||||||
if not quiet:
|
if not quiet:
|
||||||
print('Compiling', fullname, '...')
|
print('Compiling {!r}...'.format(fullname))
|
||||||
try:
|
try:
|
||||||
ok = py_compile.compile(fullname, cfile, dfile, True,
|
ok = py_compile.compile(fullname, cfile, dfile, True,
|
||||||
optimize=optimize)
|
optimize=optimize)
|
||||||
except py_compile.PyCompileError as err:
|
except py_compile.PyCompileError as err:
|
||||||
if quiet:
|
if quiet:
|
||||||
print('*** Error compiling', fullname, '...')
|
print('*** Error compiling {!r}...'.format(fullname))
|
||||||
else:
|
else:
|
||||||
print('*** ', end='')
|
print('*** ', end='')
|
||||||
# escape non-printable characters in msg
|
# escape non-printable characters in msg
|
||||||
|
@ -126,7 +126,7 @@ def compile_file(fullname, ddir=None, force=False, rx=None, quiet=False,
|
||||||
success = 0
|
success = 0
|
||||||
except (SyntaxError, UnicodeError, IOError) as e:
|
except (SyntaxError, UnicodeError, IOError) as e:
|
||||||
if quiet:
|
if quiet:
|
||||||
print('*** Error compiling', fullname, '...')
|
print('*** Error compiling {!r}...'.format(fullname))
|
||||||
else:
|
else:
|
||||||
print('*** ', end='')
|
print('*** ', end='')
|
||||||
print(e.__class__.__name__ + ':', e)
|
print(e.__class__.__name__ + ':', e)
|
||||||
|
|
|
@ -345,7 +345,7 @@ class CommandLineTests(unittest.TestCase):
|
||||||
|
|
||||||
def test_invalid_arg_produces_message(self):
|
def test_invalid_arg_produces_message(self):
|
||||||
out = self.assertRunOK('badfilename')
|
out = self.assertRunOK('badfilename')
|
||||||
self.assertRegex(out, b"Can't list badfilename")
|
self.assertRegex(out, b"Can't list 'badfilename'")
|
||||||
|
|
||||||
|
|
||||||
def test_main():
|
def test_main():
|
||||||
|
|
|
@ -86,6 +86,9 @@ Core and Builtins
|
||||||
Library
|
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
|
- Issue #10419, #6011: build_scripts command of distutils handles correctly
|
||||||
non-ASCII path (path to the Python executable). Open and write the script in
|
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
|
binary mode, but ensure that the shebang is decodable from UTF-8 and from the
|
||||||
|
|
Loading…
Reference in New Issue