Skip to content

Commit

Permalink
ansible_mitogen: Fix TypeError in set_file_owner()
Browse files Browse the repository at this point in the history
fixes #1234
  • Loading branch information
moreati committed Jan 31, 2025
1 parent 1864048 commit 9b91a1a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 4 additions & 5 deletions ansible_mitogen/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,11 +647,10 @@ def set_file_owner(path, owner, group=None, fd=None):
else:
gid = os.getegid()

if fd is not None and hasattr(os, 'fchown'):
os.fchown(fd, (uid, gid))
if fd is not None:
os.fchown(fd, uid, gid)
else:
# Python<2.6
os.chown(path, (uid, gid))
os.chown(path, uid, gid)


def write_path(path, s, owner=None, group=None, mode=None,
Expand Down Expand Up @@ -741,7 +740,7 @@ def set_file_mode(path, spec, fd=None):
mode = os.stat(path).st_mode
new_mode = apply_mode_spec(spec, mode)

if fd is not None and hasattr(os, 'fchmod'):
if fd is not None:
os.fchmod(fd, new_mode)
else:
os.chmod(path, new_mode)
Expand Down
2 changes: 2 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ In progress (unreleased)
``_low_level_execute_command()``
* :gh:issue:`1227` tests: Name transport_config tests that use ``mitogen_via``
* :gh:issue:`1143` :mod:`ansible_mitogen`: Fix dnf module include for dnf.cli
* :gh:issue:`1234` :mod:`ansible_mitogen`: Fix :exc:`TypeError` in
:func:`ansible_mitogen.target.set_file_owner`


v0.3.21 (2025-01-20)
Expand Down

0 comments on commit 9b91a1a

Please sign in to comment.