Skip to content

Commit e330071

Browse files
committed
Return None when no file created
If a user edits a new, non-existing file and decides to not save it, edit will return None instead of raising an exception.
1 parent a51b6ff commit e330071

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

editor.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,10 @@ def edit(filename=None, contents=None, use_tty=None):
9797
proc = subprocess.Popen(args, close_fds=True, stdout=stdout)
9898
proc.communicate()
9999

100-
with open(filename, mode='rb') as f:
101-
return f.read()
100+
if os.path.isfile(filename):
101+
with open(filename, mode='rb') as f:
102+
return f.read()
103+
return None
102104

103105

104106
def _get_editor(ns):

0 commit comments

Comments
 (0)