Skip to content

Commit 0347823

Browse files
committed
upgrade github actions to checkup@v3 and setup-python@v3
1 parent 112f4f9 commit 0347823

File tree

2 files changed

+33
-26
lines changed

2 files changed

+33
-26
lines changed

pathlib3x/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
__all__ = ["PurePath", "PurePosixPath", "PureWindowsPath", "Path", "PosixPath", "WindowsPath"]
2-
import pathlib as pathlib_original
2+
import sys
3+
if sys.version_info < (3, 10):
4+
import pathlib as pathlib_original
35
from .pathlib3x import *
46

57
from . import __init__conf__

pathlib3x/pathlib3x.py

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# stored under pathlib.py.txt for later, quicker comparison
55
import inspect
66
import shutil
7-
87
# /bitranox addon
98

109
# Original Pathlib imports
@@ -26,6 +25,9 @@
2625
# bitranox addon
2726
if sys.version_info < (3, 6):
2827
raise ImportError("pathlib3x is only compatible with Python 3.6 or newer")
28+
29+
if sys.version_info < (3, 10):
30+
import pathlib_original
2931
# /bitranox addon
3032

3133
__all__ = [
@@ -1064,35 +1066,38 @@ def absolute(self):
10641066
return self._from_parts([self.cwd()] + self._parts)
10651067

10661068
def resolve(self, strict=False):
1067-
"""
1068-
Make the path absolute, resolving all symlinks on the way and also
1069-
normalizing it.
1070-
"""
1069+
if sys.version_info >= (3, 10):
1070+
"""
1071+
Make the path absolute, resolving all symlinks on the way and also
1072+
normalizing it.
1073+
"""
10711074

1072-
def check_eloop(e):
1073-
winerror = getattr(e, "winerror", 0)
1074-
if e.errno == ELOOP or winerror == _WINERROR_CANT_RESOLVE_FILENAME:
1075-
raise RuntimeError("Symlink loop from %r" % e.filename)
1076-
1077-
try:
1078-
if sys.version_info >= (3, 10):
1079-
s = os.path.realpath(self, strict=strict)
1080-
else:
1081-
# bitranox - option strict will most probably not work correctly
1082-
s = os.path.realpath(self)
1083-
except OSError as e:
1084-
check_eloop(e)
1085-
raise
1086-
p = self._from_parts((s,))
1075+
def check_eloop(e):
1076+
winerror = getattr(e, "winerror", 0)
1077+
if e.errno == ELOOP or winerror == _WINERROR_CANT_RESOLVE_FILENAME:
1078+
raise RuntimeError("Symlink loop from %r" % e.filename)
10871079

1088-
# In non-strict mode, realpath() doesn't raise on symlink loops.
1089-
# Ensure we get an exception by calling stat()
1090-
if not strict:
10911080
try:
1092-
p.stat()
1081+
if sys.version_info >= (3, 10):
1082+
s = os.path.realpath(self, strict=strict)
1083+
else:
1084+
# bitranox - option strict will most probably not work correctly
1085+
s = os.path.realpath(self)
10931086
except OSError as e:
10941087
check_eloop(e)
1095-
return p
1088+
raise
1089+
p = self._from_parts((s,))
1090+
1091+
# In non-strict mode, realpath() doesn't raise on symlink loops.
1092+
# Ensure we get an exception by calling stat()
1093+
if not strict:
1094+
try:
1095+
p.stat()
1096+
except OSError as e:
1097+
check_eloop(e)
1098+
return p
1099+
else:
1100+
return pathlib_original.Path(self).resolve(strict=strict)
10961101

10971102
def stat(self, *, follow_symlinks=True):
10981103
"""

0 commit comments

Comments
 (0)