diff options
author | Shawn O. Pearce <sop@google.com> | 2009-04-18 14:48:03 -0700 |
---|---|---|
committer | Shawn O. Pearce <sop@google.com> | 2009-04-18 14:48:03 -0700 |
commit | 76ca9f8145f367f83df19981da4dd934fdda471b (patch) | |
tree | d6c095928fd2b1131972206b3c3f498843a736a6 /editor.py | |
parent | accc56d82b902e7c7a22401db710958fcb1c7b58 (diff) | |
download | git-repo-76ca9f8145f367f83df19981da4dd934fdda471b.tar.gz |
Make usage of open safer by setting binary mode and closing fds
Signed-off-by: Shawn O. Pearce <sop@google.com>
Diffstat (limited to 'editor.py')
-rw-r--r-- | editor.py | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -78,7 +78,11 @@ least one of these before using this command.""" | |||
78 | 78 | ||
79 | if subprocess.Popen(editor + [path]).wait() != 0: | 79 | if subprocess.Popen(editor + [path]).wait() != 0: |
80 | raise EditorError() | 80 | raise EditorError() |
81 | return open(path).read() | 81 | fd = open(path) |
82 | try: | ||
83 | return read() | ||
84 | finally: | ||
85 | fd.close() | ||
82 | finally: | 86 | finally: |
83 | if fd: | 87 | if fd: |
84 | os.close(fd) | 88 | os.close(fd) |