Skip to content

Commit 4b5d333

Browse files
committed
Call _getfullpathname() on the drive (if any), not the full path
1 parent 28e7831 commit 4b5d333

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

Lib/pathlib.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,7 @@
2222
try:
2323
from nt import _getfullpathname
2424
except ImportError:
25-
def _absolute_parts(path):
26-
return [os.getcwd()] + path._parts
27-
else:
28-
def _absolute_parts(path):
29-
try:
30-
return [_getfullpathname(path)]
31-
except (OSError, ValueError):
32-
return [os.getcwd()] + path._parts
25+
_getfullpathname = None
3326

3427

3528
__all__ = [
@@ -838,7 +831,14 @@ def absolute(self):
838831
"""
839832
if self.is_absolute():
840833
return self
841-
return self._from_parts(_absolute_parts(self))
834+
elif self._drv and _getfullpathname:
835+
try:
836+
cwd = _getfullpathname(self._drv)
837+
except (ValueError, OSError):
838+
cwd = os.getcwd()
839+
else:
840+
cwd = os.getcwd()
841+
return self._from_parts([cwd] + self._parts)
842842

843843
def resolve(self, strict=False):
844844
"""

0 commit comments

Comments
 (0)