Address review comments.

This commit is contained in:
Itamar Turner-Trauring 2020-08-13 15:02:49 -04:00
parent 7505abe826
commit e113cba8d0
2 changed files with 6 additions and 1 deletions

View File

@ -53,7 +53,9 @@ if __name__ == "__main__":
for fname in TEST_FILENAMES:
open(os.path.join(tmpdir, fname), 'w').close()
# Use Unicode API under Windows or MacOS X
# On Python 2, listing directories returns unicode under Windows or
# MacOS X if the input is unicode. On Python 3, it always returns
# Unicode.
if PY2 and sys.platform in ('win32', 'darwin'):
dirlist = os.listdir(unicode(tmpdir))
else:

View File

@ -214,6 +214,9 @@ def _unicode_escape(m, quote_newlines):
return u'\\x%02x' % (codepoint,)
def _str_escape(m, quote_newlines): # TODO rename to _bytes_escape
"""
Takes a re match on bytes, the result is escaped bytes of group(0).
"""
c = m.group(0)
if c == b'"' or c == b'$' or c == b'`' or c == b'\\':
return b'\\' + c