{"record":{"id":"27d2b4f3b2e4ef8c","repo":"arduino/Arduino","slug":"sep-must-be-none-or-a-string","errorCode":null,"errorMessage":"sep must be None or a string","messagePattern":"sep must be None or a string","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"arduino-core/src/processing/app/i18n/python/requests/packages/urllib3/packages/six.py","lineNumber":350,"sourceCode":"\"\"\")\n\n\n    def print_(*args, **kwargs):\n        \"\"\"The new-style print function.\"\"\"\n        fp = kwargs.pop(\"file\", sys.stdout)\n        if fp is None:\n            return\n        def write(data):\n            if not isinstance(data, basestring):\n                data = str(data)\n            fp.write(data)\n        want_unicode = False\n        sep = kwargs.pop(\"sep\", None)\n        if sep is not None:\n            if isinstance(sep, unicode):\n                want_unicode = True\n            elif not isinstance(sep, str):\n                raise TypeError(\"sep must be None or a string\")\n        end = kwargs.pop(\"end\", None)\n        if end is not None:\n            if isinstance(end, unicode):\n                want_unicode = True\n            elif not isinstance(end, str):\n                raise TypeError(\"end must be None or a string\")\n        if kwargs:\n            raise TypeError(\"invalid keyword arguments to print()\")\n        if not want_unicode:\n            for arg in args:\n                if isinstance(arg, unicode):\n                    want_unicode = True\n                    break\n        if want_unicode:\n            newline = unicode(\"\\n\")\n            space = unicode(\" \")\n        else:\n            newline = \"\\n\"","sourceCodeStart":332,"sourceCodeEnd":368,"githubUrl":"https://github.com/arduino/Arduino/blob/a0df6e0e83b652c72bc78b0a1376c54d6ebc3bee/arduino-core/src/processing/app/i18n/python/requests/packages/urllib3/packages/six.py#L332-L368","documentation":"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.","triggerScenarios":"six.print_('a', 'b', sep=1); passing a list/tuple as sep; passing sep=None-like sentinel objects that are not str/unicode.","commonSituations":"Programmatically building separator values from config; translating Python 3 code where sep accepts anything str()-able; mixing bytes and text on Python 2.","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."],"exampleFix":"// before\nsix.print_('a', 'b', sep=['-'])\n// after\nsix.print_('a', 'b', sep='-')","handlingStrategy":"validation","validationCode":"if sep is not None and not isinstance(sep, (str, unicode)):\n    sep = str(sep)","typeGuard":"def is_valid_sep(sep):\n    return sep is None or isinstance(sep, (str, unicode))","tryCatchPattern":"try:\n    six.print_(*args, sep=sep)\nexcept TypeError as e:\n    if 'sep must be None or a string' in str(e):\n        six.print_(*args, sep=str(sep))\n    else:\n        raise","preventionTips":["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."],"tags":["python","six","typeerror","print"],"backgroundTag":"invalid-argument-value","analyzedSha":"a0df6e0e83b652c72bc78b0a1376c54d6ebc3bee","analyzedAt":"2026-09-06T10:13:38.901Z","contentChangedAt":"2026-09-06T10:13:38.901Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}