mirror of
https://github.com/python/cpython.git
synced 2025-07-09 20:35:26 +00:00
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:
parent
9573638c2d
commit
cb5ec77d33
4 changed files with 36 additions and 2 deletions
|
@ -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"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue