Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d3590f9

Browse files
committed
Only log a message and chmod() when the mode isn't already what we
want it to be. Log both the old and new mode.
1 parent 6afc5e0 commit d3590f9

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

Lib/distutils/command/build_scripts.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,12 @@ def copy_scripts (self):
114114
if self.dry_run:
115115
log.info("changing mode of %s", file)
116116
else:
117-
mode = ((os.stat(file)[ST_MODE]) | 0555) & 07777
118-
log.info("changing mode of %s to %o", file, mode)
119-
os.chmod(file, mode)
117+
oldmode = os.stat(file)[ST_MODE] & 07777
118+
newmode = (oldmode | 0555) & 07777
119+
if newmode != oldmode:
120+
log.info("changing mode of %s from %o to %o",
121+
file, oldmode, newmode)
122+
os.chmod(file, newmode)
120123

121124
# copy_scripts ()
122125

0 commit comments

Comments
 (0)