Issue #21127: Path objects can now be instantiated from str subclass instances (such as numpy.str_).

Thanks to Antony Lee for the report and preliminary patch.
This commit is contained in:
Antoine Pitrou 2014-04-23 00:34:15 +02:00
parent 9573638c2d
commit cb5ec77d33
4 changed files with 36 additions and 2 deletions

View file

@ -574,8 +574,8 @@ class PurePath(object):
if isinstance(a, PurePath):
parts += a._parts
elif isinstance(a, str):
# Assuming a str
parts.append(a)
# Force-cast str subclasses to str (issue #21127)
parts.append(str(a))
else:
raise TypeError(
"argument should be a path or str object, not %r"