aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--netlib/strutils.py4
-rw-r--r--test/netlib/test_strutils.py5
2 files changed, 5 insertions, 4 deletions
diff --git a/netlib/strutils.py b/netlib/strutils.py
index a51df886..32e77927 100644
--- a/netlib/strutils.py
+++ b/netlib/strutils.py
@@ -57,8 +57,8 @@ def escape_control_characters(text, keep_spacing=True):
Args:
keep_spacing: If True, tabs and newlines will not be replaced.
"""
- # type: (six.text_type) -> six.text_type
- if not isinstance(text, six.text_type):
+ # type: (six.string_types) -> six.text_type
+ if not isinstance(text, six.string_types):
raise ValueError("text type must be unicode but is {}".format(type(text).__name__))
trans = _control_char_trans_newline if keep_spacing else _control_char_trans
diff --git a/test/netlib/test_strutils.py b/test/netlib/test_strutils.py
index 68bfdb94..7c3eacc6 100644
--- a/test/netlib/test_strutils.py
+++ b/test/netlib/test_strutils.py
@@ -38,8 +38,9 @@ def test_escape_control_characters():
u'=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~.'
)
- with tutils.raises(ValueError):
- strutils.escape_control_characters(b"foo")
+ if not six.PY2:
+ with tutils.raises(ValueError):
+ strutils.escape_control_characters(b"foo")
def test_bytes_to_escaped_str():