Bug 1547730 - Don't try to py3-ize indented_repr yet. r=glandium

Differential Revision: https://phabricator.services.mozilla.com/D28103

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Justin Wood 2019-05-28 14:25:23 +00:00
Родитель c1cc1ca1dc
Коммит 865e39b01a
1 изменённых файлов: 14 добавлений и 11 удалений

Просмотреть файл

@ -1227,17 +1227,18 @@ def _escape_char(c):
return six.text_type(c.encode('unicode_escape')) return six.text_type(c.encode('unicode_escape'))
# Mapping table between raw characters below \x80 and their escaped if six.PY2: # Not supported for py3 yet
# counterpart, when they differ # Mapping table between raw characters below \x80 and their escaped
_INDENTED_REPR_TABLE = { # counterpart, when they differ
c: e _INDENTED_REPR_TABLE = {
for c, e in map(lambda x: (x, _escape_char(x)), c: e
map(unichr, range(128))) for c, e in map(lambda x: (x, _escape_char(x)),
if c != e map(unichr, range(128)))
} if c != e
# Regexp matching all characters to escape. }
_INDENTED_REPR_RE = re.compile( # Regexp matching all characters to escape.
'([' + ''.join(_INDENTED_REPR_TABLE.values()) + ']+)') _INDENTED_REPR_RE = re.compile(
'([' + ''.join(_INDENTED_REPR_TABLE.values()) + ']+)')
def indented_repr(o, indent=4): def indented_repr(o, indent=4):
@ -1246,6 +1247,8 @@ def indented_repr(o, indent=4):
One notable difference with repr is that the returned representation One notable difference with repr is that the returned representation
assumes `from __future__ import unicode_literals`. assumes `from __future__ import unicode_literals`.
''' '''
if six.PY3:
raise NotImplementedError("indented_repr is not yet supported on py3")
one_indent = ' ' * indent one_indent = ' ' * indent
def recurse_indented_repr(o, level): def recurse_indented_repr(o, level):