diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2014-04-22 22:34:15 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2014-04-22 22:34:15 (GMT) |
commit | cb5ec77d33f1c6db2e0e1684d8ebf9c4cf7346b9 (patch) | |
tree | f815b6c25c56fee57fcfc95e869c58392a86aee4 /Lib/pathlib.py | |
parent | 9573638c2dd36af531ec922bc364b438d7b1f427 (diff) | |
download | cpython-cb5ec77d33f1c6db2e0e1684d8ebf9c4cf7346b9.zip cpython-cb5ec77d33f1c6db2e0e1684d8ebf9c4cf7346b9.tar.gz cpython-cb5ec77d33f1c6db2e0e1684d8ebf9c4cf7346b9.tar.bz2 |
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.
Diffstat (limited to 'Lib/pathlib.py')
-rw-r--r-- | Lib/pathlib.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Lib/pathlib.py b/Lib/pathlib.py index 8d08e8b..d3d1af8 100644 --- a/Lib/pathlib.py +++ b/Lib/pathlib.py @@ -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" |