tensorflow/models · error · ValueError
Unsupported string type: %s
Error message
Unsupported string type: %s
What it means
Error "Unsupported string type: %s" thrown in tensorflow/models.
Source
Thrown at official/legacy/xlnet/preprocess_utils.py:35
import unicodedata
import six
SPIECE_UNDERLINE = '▁'
def printable_text(text):
"""Returns text encoded in a way suitable for print or `tf.logging`."""
# These functions want `str` for both Python2 and Python3, but in one case
# it's a Unicode string and in the other it's a byte string.
if six.PY3:
if isinstance(text, str):
return text
elif isinstance(text, bytes):
return text.decode('utf-8', 'ignore')
else:
raise ValueError('Unsupported string type: %s' % (type(text)))
elif six.PY2:
if isinstance(text, str):
return text
elif isinstance(text, unicode): # pylint: disable=undefined-variable
return text.encode('utf-8')
else:
raise ValueError('Unsupported string type: %s' % (type(text)))
else:
raise ValueError('Not running on Python2 or Python 3?')
def print_(*args):
new_args = []
for arg in args:
if isinstance(arg, list):
s = [printable_text(i) for i in arg]
s = ' '.join(s)
new_args.append(s)View on GitHub (pinned to e006f5f0d5)
When it happens
Trigger: Thrown at official/legacy/xlnet/preprocess_utils.py:35 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of tensorflow/models@e006f5f0d5 (2026-08-24).
Data as JSON: /api/errors/bb4940c46a2e680d.
Report an issue: GitHub.