Skip to content
Prev Previous commit
Next Next commit
Apply suggestions from code review
Co-authored-by: Steve Dower <steve.dower@microsoft.com>
  • Loading branch information
barneygale and zooba authored Mar 27, 2023
commit e54a6872f5cb063d721206ff46db25d07b447e99
8 changes: 4 additions & 4 deletions Lib/pathlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ def __truediv__(self, key):

def __rtruediv__(self, key):
try:
return self.__class__(key, self._raw_path)
return type(self)(key, self._raw_path)
except TypeError:
return NotImplemented

Expand Down Expand Up @@ -818,7 +818,7 @@ def absolute(self):
cwd = self._flavour.abspath(self.drive)
else:
cwd = os.getcwd()
return self.__class__(cwd, self._raw_path)
return type(self)(cwd, self._raw_path)

def resolve(self, strict=False):
"""
Expand All @@ -836,7 +836,7 @@ def check_eloop(e):
except OSError as e:
check_eloop(e)
raise
p = self.__class__(s)
p = type(self)(s)

# In non-strict mode, realpath() doesn't raise on symlink loops.
# Ensure we get an exception by calling stat()
Expand Down Expand Up @@ -926,7 +926,7 @@ def readlink(self):
"""
if not hasattr(os, "readlink"):
raise NotImplementedError("os.readlink() not available on this system")
return self.__class__(os.readlink(self))
return type(self)(os.readlink(self))

def touch(self, mode=0o666, exist_ok=True):
"""
Expand Down