Bad error message when EDITOR is not set.

Bug #28636 reported by xxx
0
Affects Status Importance Assigned to Milestone
Bazaar
Fix Released
Low
Unassigned

Bug Description

example:
% unset EDITOR
% bzr commit
bzr: ERROR: [Errno 2] No such file or directory
  command: '/usr/bin/bzr' 'commit'
      pwd: u'xxx.py'
    error: exceptions.OSError
  at /usr/lib/python2.4/subprocess.py line 975, in _execute_child()
  see ~/.bzr.log for debug information
%

Traceback (most recent call last):
  File "/usr/lib/python2.4/site-packages/bzrlib/commands.py", line 522, in run_bzr_catch_errors
    return run_bzr(argv)
  File "/usr/lib/python2.4/site-packages/bzrlib/commands.py", line 497, in run_bzr
    ret = cmd_obj.run_argv(argv)
  File "/usr/lib/python2.4/site-packages/bzrlib/commands.py", line 215, in run_argv
    return self.run(**all_cmd_args)
  File "/usr/lib/python2.4/site-packages/bzrlib/builtins.py", line 1104, in run
    message = edit_commit_message(catcher.getvalue())
  File "/usr/lib/python2.4/site-packages/bzrlib/msgeditor.py", line 92, in edit_commit_message
    if not _run_editor(msgfilename):
  File "/usr/lib/python2.4/site-packages/bzrlib/msgeditor.py", line 54, in _run_editor
    x = call(edargs + [filename])
  File "/usr/lib/python2.4/subprocess.py", line 412, in call
    return Popen(*args, **kwargs).wait()
  File "/usr/lib/python2.4/subprocess.py", line 542, in __init__
    errread, errwrite)
  File "/usr/lib/python2.4/subprocess.py", line 975, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

description: updated
Revision history for this message
John A Meinel (jameinel) wrote :

In 0.7 if EDITOR and BZR_EDITOR are not set, bzr tries to use a reasonable editor based on platform.

However, if EDITOR is set to something non-existant, we fail to trap the exception.
$ EDITOR=bogus bzr commit
bzr: ERROR: exceptions.OSError: [Errno 2] No such file or directory
  at /usr/lib/python2.4/subprocess.py line 975
  in _execute_child

We probably just want a try/except around the subprocess.call() function at line 54 in msgeditor.py

Something like this:
=== modified file 'bzrlib/msgeditor.py'
--- bzrlib/msgeditor.py
+++ bzrlib/msgeditor.py
@@ -20,6 +20,7 @@
 """Commit message editor support."""

 import os
+import errno
 from subprocess import call

 import bzrlib.config as config
@@ -51,7 +52,13 @@
     """Try to execute an editor to edit the commit message."""
     for e in _get_editor():
         edargs = e.split(' ')
- x = call(edargs + [filename])
+ try:
+ x = call(edargs + [filename])
+ except OSError, e:
+ # ENOENT means no such editor
+ if e.errno == errno.ENOENT:
+ continue
+ raise
         if x == 0:
             return True
         elif x == 127:

Present on my jam-pending branch (revno 1509)

Changed in bzr:
status: Unconfirmed → In Progress
James Blackwell (jblack)
Changed in bzr:
status: In Progress → Fix Committed
Changed in bzr:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.