Based on a patch by Nick Coghlan.
else:
path += sep + b
except TypeError:
- strs = [isinstance(s, str) for s in (a, ) + p]
- if any(strs) and not all(strs):
+ valid_types = all(isinstance(s, (str, bytes, bytearray))
+ for s in (a, ) + p)
+ if valid_types:
+ # Must have a mixture of text and binary data
- raise TypeError("Can't mix strings and bytes in path components.")
+ raise TypeError("Can't mix strings and bytes in path "
+ "components.") from None
- else:
- raise
+ raise
return path
-import unittest
-from test import support, test_genericpath
-
+ import itertools
-import posixpath
import os
+import posixpath
import sys
+import unittest
+import warnings
from posixpath import realpath, abspath, dirname, basename
+from test import support, test_genericpath
try:
import posix