Skip to content

Commit 8fe8b1d

Browse files
committed
minstall: fix symlink handling on python 3.13
We passed a wrapper hack for shutil.chown because some functionality wasn't available in the stdlib. It was added in python 3.13 beta1, so the tests fail when we actually test symlink handling. Fixes failure to run test_install_subdir_symlinks_with_default_umask_and_mode on python 3.13.
1 parent eba5498 commit 8fe8b1d

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

mesonbuild/minstall.py

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -148,23 +148,29 @@ def set_chown(path: str, user: T.Union[str, int, None] = None,
148148
# be actually passed properly.
149149
# Not nice, but better than actually rewriting shutil.chown until
150150
# this python bug is fixed: https://bugs.python.org/issue18108
151-
real_os_chown = os.chown
152151

153-
def chown(path: T.Union[int, str, 'os.PathLike[str]', bytes, 'os.PathLike[bytes]'],
154-
uid: int, gid: int, *, dir_fd: T.Optional[int] = dir_fd,
155-
follow_symlinks: bool = follow_symlinks) -> None:
156-
"""Override the default behavior of os.chown
152+
if sys.version_info >= (3, 13):
153+
# pylint: disable=unexpected-keyword-arg
154+
# cannot handle sys.version_info, https://github.com/pylint-dev/pylint/issues/9138
155+
shutil.chown(path, user, group, dir_fd=dir_fd, follow_symlinks=follow_symlinks)
156+
else:
157+
real_os_chown = os.chown
157158

158-
Use a real function rather than a lambda to help mypy out. Also real
159-
functions are faster.
160-
"""
161-
real_os_chown(path, uid, gid, dir_fd=dir_fd, follow_symlinks=follow_symlinks)
159+
def chown(path: T.Union[int, str, 'os.PathLike[str]', bytes, 'os.PathLike[bytes]'],
160+
uid: int, gid: int, *, dir_fd: T.Optional[int] = dir_fd,
161+
follow_symlinks: bool = follow_symlinks) -> None:
162+
"""Override the default behavior of os.chown
162163
163-
try:
164-
os.chown = chown
165-
shutil.chown(path, user, group)
166-
finally:
167-
os.chown = real_os_chown
164+
Use a real function rather than a lambda to help mypy out. Also real
165+
functions are faster.
166+
"""
167+
real_os_chown(path, uid, gid, dir_fd=dir_fd, follow_symlinks=follow_symlinks)
168+
169+
try:
170+
os.chown = chown
171+
shutil.chown(path, user, group)
172+
finally:
173+
os.chown = real_os_chown
168174

169175

170176
def set_chmod(path: str, mode: int, dir_fd: T.Optional[int] = None,

0 commit comments

Comments
 (0)