From 76ca9f8145f367f83df19981da4dd934fdda471b Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Sat, 18 Apr 2009 14:48:03 -0700 Subject: Make usage of open safer by setting binary mode and closing fds Signed-off-by: Shawn O. Pearce --- editor.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'editor.py') diff --git a/editor.py b/editor.py index a297470d..34c9ad1f 100644 --- a/editor.py +++ b/editor.py @@ -78,7 +78,11 @@ least one of these before using this command.""" if subprocess.Popen(editor + [path]).wait() != 0: raise EditorError() - return open(path).read() + fd = open(path) + try: + return read() + finally: + fd.close() finally: if fd: os.close(fd) -- cgit v1.2.3-54-g00ecf