Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-104898: Revert pathlib os.PathLike registration change. #105073

Merged
merged 2 commits into from
May 29, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Lib/pathlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ def __repr__(self):
return "<{}.parents>".format(type(self._path).__name__)


class PurePath(os.PathLike):
class PurePath:
"""Base class for manipulating paths without I/O.

PurePath represents a filesystem path and offers operations which
Expand Down Expand Up @@ -715,6 +715,9 @@ def match(self, path_pattern, *, case_sensitive=None):
return False
return True

# Subclassing os.PathLike makes __instancecheck__ slower. Register instead!
barneygale marked this conversation as resolved.
Show resolved Hide resolved
os.PathLike.register(PurePath)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that you can use ABC.register as a class decorator, but I think it would not look better for this case.



class PurePosixPath(PurePath):
"""PurePath subclass for non-Windows systems.
Expand Down