Skip to content

Commit ad438f1

Browse files
committed
Merge pull request jaraco#94 from mbruzek/fix-chown
Changing the chown method to always be defined
2 parents e5d21d9 + 4866dfe commit ad438f1

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

‎path.py‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,15 +1133,21 @@ def chmod(self, mode):
11331133
os.chmod(self, mode)
11341134
return self
11351135

1136-
if hasattr(os, 'chown'):
1137-
def chown(self, uid=-1, gid=-1):
1138-
""" .. seealso:: :func:`os.chown` """
1136+
def chown(self, uid=-1, gid=-1):
1137+
"""
1138+
Change the owner and group by names rather than the uid or gid numbers.
1139+
1140+
.. seealso:: :func:`os.chown`
1141+
"""
1142+
if hasattr(os, 'chown'):
11391143
if 'pwd' in globals() and isinstance(uid, string_types):
11401144
uid = pwd.getpwnam(uid).pw_uid
11411145
if 'grp' in globals() and isinstance(gid, string_types):
11421146
gid = grp.getgrnam(gid).gr_gid
11431147
os.chown(self, uid, gid)
1144-
return self
1148+
else:
1149+
raise NotImplementedError("Ownership not available on this platform.")
1150+
return self
11451151

11461152
def rename(self, new):
11471153
""" .. seealso:: :func:`os.rename` """

0 commit comments

Comments
 (0)