Disallow BlendPath(str)

This commit is contained in:
Sybren A. Stüvel
2018-03-08 14:18:07 +01:00
parent f2f824ad85
commit e9ee5b69ec
2 changed files with 6 additions and 16 deletions
+4 -4
View File
@@ -15,10 +15,10 @@ class BlendPath(bytes):
def __new__(cls, path):
if isinstance(path, pathlib.Path):
path = str(path) # handle as string, which is encoded to bytes below.
if isinstance(path, str):
# As a convenience, when a string is given, interpret as UTF-8.
return bytes.__new__(cls, path.encode('utf-8'))
path = str(path).encode('utf-8')
if not isinstance(path, bytes):
raise TypeError('path must be bytes or pathlib.Path, but is %r' % path)
return bytes.__new__(cls, path)
@classmethod