arduino/Arduino · error · TypeError
sep must be None or a string
Error message
sep must be None or a string
What it means
six.print_ is the Python 2 emulation of the print() function. Its sep keyword must be None, a str, or a unicode string; passing any other type (int, list, bytes-like object in a Py2 context, etc.) raises this TypeError before any output is produced.
Source
Thrown at arduino-core/src/processing/app/i18n/python/requests/packages/urllib3/packages/six.py:350
""")
def print_(*args, **kwargs):
"""The new-style print function."""
fp = kwargs.pop("file", sys.stdout)
if fp is None:
return
def write(data):
if not isinstance(data, basestring):
data = str(data)
fp.write(data)
want_unicode = False
sep = kwargs.pop("sep", None)
if sep is not None:
if isinstance(sep, unicode):
want_unicode = True
elif not isinstance(sep, str):
raise TypeError("sep must be None or a string")
end = kwargs.pop("end", None)
if end is not None:
if isinstance(end, unicode):
want_unicode = True
elif not isinstance(end, str):
raise TypeError("end must be None or a string")
if kwargs:
raise TypeError("invalid keyword arguments to print()")
if not want_unicode:
for arg in args:
if isinstance(arg, unicode):
want_unicode = True
break
if want_unicode:
newline = unicode("\n")
space = unicode(" ")
else:
newline = "\n"View on GitHub (pinned to a0df6e0e83)
Solutions
- Pass a string separator: sep=', ' or sep=None.
- Coerce non-string separators before the call: sep=str(value) or sep=', '.join(parts).
- Drop the sep argument entirely and rely on the default single space.
Example fix
// before
six.print_('a', 'b', sep=['-'])
// after
six.print_('a', 'b', sep='-') Defensive patterns
Strategy: validation
Validate before calling
if sep is not None and not isinstance(sep, (str, unicode)):
sep = str(sep) Type guard
def is_valid_sep(sep):
return sep is None or isinstance(sep, (str, unicode)) Try / catch
try:
six.print_(*args, sep=sep)
except TypeError as e:
if 'sep must be None or a string' in str(e):
six.print_(*args, sep=str(sep))
else:
raise Prevention
- Only pass str/unicode (or None) as sep.
- Coerce dynamically computed separators with str() before the call.
- Watch for Python 2 bytes vs unicode mixing when building separators.
When it happens
Trigger: six.print_('a', 'b', sep=1); passing a list/tuple as sep; passing sep=None-like sentinel objects that are not str/unicode.
Common situations: Programmatically building separator values from config; translating Python 3 code where sep accepts anything str()-able; mixing bytes and text on Python 2.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- end must be None or a string
- invalid keyword arguments to print()
- expected at most 1 arguments, got %d
- update() takes at most 2 positional arguments (%d given)
- update() takes at least 1 argument (0 given)
AI-assisted analysis of arduino/Arduino@a0df6e0e83 (2026-09-06).
Data as JSON: /api/errors/27d2b4f3b2e4ef8c.
Report an issue: GitHub.