aboutsummaryrefslogtreecommitdiffstats
path: root/library/python
diff options
context:
space:
mode:
Diffstat (limited to 'library/python')
-rw-r--r--library/python/strings/__init__.py1
-rw-r--r--library/python/strings/strings.py7
2 files changed, 8 insertions, 0 deletions
diff --git a/library/python/strings/__init__.py b/library/python/strings/__init__.py
index bd6bf6e7ce..c7da1463cf 100644
--- a/library/python/strings/__init__.py
+++ b/library/python/strings/__init__.py
@@ -4,6 +4,7 @@ from .strings import (
DEFAULT_ENCODING,
ENCODING_ERRORS_POLICY,
encode,
+ ensure_str_deep,
fs_encoding,
get_stream_encoding,
guess_default_encoding,
diff --git a/library/python/strings/strings.py b/library/python/strings/strings.py
index 1005b2fe97..916ae96742 100644
--- a/library/python/strings/strings.py
+++ b/library/python/strings/strings.py
@@ -82,10 +82,17 @@ def _convert_deep(x, enc, convert, relaxed=True):
raise TypeError('unsupported type')
+# Result as from six.ensure_text
def unicodize_deep(x, enc=DEFAULT_ENCODING, relaxed=True):
return _convert_deep(x, enc, to_unicode, relaxed)
+# Result as from six.ensure_str
+def ensure_str_deep(x, enc=DEFAULT_ENCODING, relaxed=True):
+ return _convert_deep(x, enc, six.ensure_str, relaxed)
+
+
+# Result as from six.ensure_binary
def stringize_deep(x, enc=DEFAULT_ENCODING, relaxed=True):
return _convert_deep(x, enc, to_str, relaxed)