We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 28e7831 commit 4b5d333Copy full SHA for 4b5d333
1 file changed
Lib/pathlib.py
@@ -22,14 +22,7 @@
22
try:
23
from nt import _getfullpathname
24
except ImportError:
25
- def _absolute_parts(path):
26
- return [os.getcwd()] + path._parts
27
-else:
28
29
- try:
30
- return [_getfullpathname(path)]
31
- except (OSError, ValueError):
32
+ _getfullpathname = None
33
34
35
__all__ = [
@@ -838,7 +831,14 @@ def absolute(self):
838
831
"""
839
832
if self.is_absolute():
840
833
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):
+ cwd = os.getcwd()
+ else:
+ return self._from_parts([cwd] + self._parts)
842
843
def resolve(self, strict=False):
844
0 commit comments