1414from __future__ import absolute_import
1515from __future__ import unicode_literals
1616
17- import sys
18-
19- _PY3 = sys .version_info [0 :2 ] > (3 , 0 )
20-
21- if _PY3 :
22- binary_type = bytes
23- text_type = str
24- else :
25- binary_type = str
26- # pylint: disable=unicode-builtin, undefined-variable
27- # noinspection PyUnresolvedReferences
28- text_type = unicode # NOQA
29- # pylint: enable=unicode-builtin, undefined-variable
17+ import six
3018
3119
3220def _strings_repr (indent , val ):
3321 """Custom repr for strings and binary strings."""
34- if isinstance (val , binary_type ):
22+ if isinstance (val , six . binary_type ):
3523 val = val .decode (
3624 encoding = 'utf-8' ,
3725 errors = 'backslashreplace'
@@ -66,8 +54,8 @@ def _set_repr(indent, val):
6654s_repr_formatters = {
6755 'default' : "{spc:<{indent}}{val!r}" .format ,
6856 set : _set_repr ,
69- binary_type : _strings_repr ,
70- text_type : _strings_repr ,
57+ six . binary_type : _strings_repr ,
58+ six . text_type : _strings_repr ,
7159}
7260
7361
@@ -85,7 +73,7 @@ def _set_repr(indent, val):
8573
8674def _strings_str (indent , val ):
8775 """Custom repr for strings and binary strings."""
88- if isinstance (val , binary_type ):
76+ if isinstance (val , six . binary_type ):
8977 val = val .decode (
9078 encoding = 'utf-8' ,
9179 errors = 'backslashreplace'
@@ -116,8 +104,8 @@ def _set_str(indent, val):
116104s_str_formatters = {
117105 'default' : "{spc:<{indent}}{val!s}" .format ,
118106 set : _set_str ,
119- binary_type : _strings_str ,
120- text_type : _strings_str ,
107+ six . binary_type : _strings_str ,
108+ six . text_type : _strings_str ,
121109}
122110
123111
0 commit comments