]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Fix cstyle-file.py when emacs is not installed 445/head
authorGreg Hudson <ghudson@mit.edu>
Mon, 2 May 2016 16:51:03 +0000 (12:51 -0400)
committerGreg Hudson <ghudson@mit.edu>
Tue, 3 May 2016 17:25:18 +0000 (13:25 -0400)
emacs_reindent() is intended to fail gracefully when emacs is not
installed, but instead subprocess.call() throws an OSError.  Check for
this error and return normally.

src/util/cstyle-file.py

index a080feff31f6e0801c4d6d971aaf69f7fea5572b..7e90b661f7a291f5646ba5f9d5362faf17cf9eb6 100644 (file)
@@ -76,7 +76,12 @@ def emacs_reindent(lines):
         args = ['emacs', '-q', '-batch', '-l', cstyle_el, '-l', reindent_el,
                 f.name]
         with open(os.devnull, 'w') as devnull:
-            if call(args, stdin=devnull, stdout=devnull, stderr=devnull) != 0:
+            try:
+                st = call(args, stdin=devnull, stdout=devnull, stderr=devnull)
+                if st != 0:
+                    return None
+            except OSError:
+                # Fail gracefully if emacs isn't installed.
                 return None
         f.seek(0)
         ilines = f.readlines()