Skip to content

Commit 5fdd175

Browse files
committed
Move registration into _abc
1 parent 65558be commit 5fdd175

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

Lib/pathlib/_abc.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import functools
1515
from abc import ABC, abstractmethod
1616
from glob import _PathGlobber, _no_recurse_symlinks
17+
from pathlib import PurePath, Path
1718
from pathlib._os import magic_open, CopyReader, CopyWriter
1819

1920

@@ -206,7 +207,6 @@ def full_match(self, pattern, *, case_sensitive=None):
206207
return match(str(self)) is not None
207208

208209

209-
210210
class ReadablePath(JoinablePath):
211211
"""Abstract base class for readable path objects.
212212
@@ -446,3 +446,8 @@ def write_text(self, data, encoding=None, errors=None, newline=None):
446446
return f.write(data)
447447

448448
_copy_writer = property(CopyWriter)
449+
450+
451+
JoinablePath.register(PurePath)
452+
ReadablePath.register(Path)
453+
WritablePath.register(Path)

Lib/pathlib/_local.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
grp = None
2121

2222
from pathlib._os import LocalCopyReader, LocalCopyWriter, PathInfo, DirEntryInfo
23-
from pathlib._abc import JoinablePath, ReadablePath, WritablePath
2423

2524

2625
__all__ = [
@@ -65,7 +64,7 @@ def __repr__(self):
6564
return "<{}.parents>".format(type(self._path).__name__)
6665

6766

68-
class PurePath(JoinablePath):
67+
class PurePath:
6968
"""Base class for manipulating paths without I/O.
7069
7170
PurePath represents a filesystem path and offers operations which
@@ -587,7 +586,6 @@ def match(self, path_pattern, *, case_sensitive=None):
587586
# Subclassing abc.ABC makes isinstance() checks slower,
588587
# which in turn makes path construction slower. Register instead!
589588
os.PathLike.register(PurePath)
590-
JoinablePath.register(PurePath)
591589

592590

593591
class PurePosixPath(PurePath):
@@ -1233,11 +1231,6 @@ def from_uri(cls, uri):
12331231
raise ValueError(f"URI is not absolute: {uri!r}")
12341232
return path
12351233

1236-
# Subclassing abc.ABC makes isinstance() checks slower,
1237-
# which in turn makes path construction slower. Register instead!
1238-
ReadablePath.register(Path)
1239-
WritablePath.register(Path)
1240-
12411234

12421235
class PosixPath(Path, PurePosixPath):
12431236
"""Path subclass for non-Windows systems.

0 commit comments

Comments
 (0)