[ python-Bugs-1050828 ] reindent.py strips execute permission on Unix

SourceForge.net noreply at sourceforge.net
Tue Oct 26 04:57:45 CEST 2004


Bugs item #1050828, was opened at 2004-10-20 12:48
Message generated for change (Comment added) made by facundobatista
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1050828&group_id=5470

Category: Demos and Tools
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: David Ripton (dripton)
Assigned to: Tim Peters (tim_one)
Summary: reindent.py strips execute permission on Unix

Initial Comment:
Tools/scripts/reindent.py strips execute permission
from its target file.

If the tool detects that changes need to be made, then
the target file is renamed to its original name +
'.bak', then a new file is created with the original
file's name and its whitespace-modified contents.  No
manipulation of the new file's permissions is done, so
it ends up with the default for the user's umask.

This makes reindent.py annoying to run in an automated
fashion, if you rely on execute permission.

The fix is trivial, except for portability.  Here's the
Posix-only version:

+            if os.name == "posix":
+                mode = os.stat(bak).st_mode
+                os.chmod(file, mode)

Patch available upon request.

----------------------------------------------------------------------

>Comment By: Facundo Batista (facundobatista)
Date: 2004-10-25 23:57

Message:
Logged In: YES 
user_id=752496

Attaching the file.

----------------------------------------------------------------------

Comment By: Facundo Batista (facundobatista)
Date: 2004-10-24 18:20

Message:
Logged In: YES 
user_id=752496

Instead of renaming the file and creating a new one, just
copied the original and that's all (the target file is open
with write mode, the content replaced, but the permissions
stay).

A patch is attached.

Tim, I'm assigning this to you to doublecheck (not found
unit tests for this script).

.    Facundo

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1050828&group_id=5470


More information about the Python-bugs-list mailing list