Assume os.path.isjunction is available
now that we depend on Python 3.12+
This commit is contained in:
parent
a3bae5a40c
commit
05abf4e953
@ -132,8 +132,7 @@ def make_tree_writable(topdir: PathLike) -> None:
|
||||
chmod(os.path.join(root, d))
|
||||
# Work around Python bug following junctions
|
||||
# https://github.com/python/cpython/issues/67596#issuecomment-1918112817
|
||||
if hasattr(os.path, 'isjunction'): # Python 3.12 only
|
||||
dirs[:] = [d for d in dirs if not os.path.isjunction(os.path.join(root, d))]
|
||||
dirs[:] = [d for d in dirs if not os.path.isjunction(os.path.join(root, d))]
|
||||
for fname in files:
|
||||
fpath = os.path.join(root, fname)
|
||||
if os.path.isfile(fpath):
|
||||
@ -143,8 +142,6 @@ def make_tree_writable(topdir: PathLike) -> None:
|
||||
def remove_junctions(topdir: PathLike) -> None:
|
||||
# work around a git issue where it can't handle junctions
|
||||
# https://github.com/git-for-windows/git/issues/5320
|
||||
if not hasattr(os.path, 'isjunction'): # Python 3.12 only
|
||||
return
|
||||
for root, dirs, _ in os.walk(topdir):
|
||||
no_junctions = []
|
||||
for d in dirs:
|
||||
|
||||
@ -19,7 +19,7 @@ def test_make_tree_writable():
|
||||
file_path.write_text("content")
|
||||
|
||||
# Create a junction loop if possible, to make sure we ignore it
|
||||
if hasattr(os.path, 'isjunction') and os.name == 'nt':
|
||||
if os.name == 'nt':
|
||||
import _winapi
|
||||
_winapi.CreateJunction(str(nested_dir), str(nested_junction))
|
||||
else:
|
||||
@ -44,7 +44,7 @@ def test_remove_junctions():
|
||||
nested_dir.mkdir()
|
||||
|
||||
# Create a junction loop if possible, to make sure we ignore it
|
||||
if hasattr(os.path, 'isjunction') and os.name == 'nt':
|
||||
if os.name == 'nt':
|
||||
import _winapi
|
||||
_winapi.CreateJunction(str(nested_dir), str(nested_junction))
|
||||
assert nested_junction.exists()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user