krb5 commit: Fix cstyle-file.py when emacs is not installed

Greg Hudson ghudson at mit.edu
Tue May 3 13:38:55 EDT 2016


https://github.com/krb5/krb5/commit/0f35ac91b7755d60e97d95ff41725c21dbce5f55
commit 0f35ac91b7755d60e97d95ff41725c21dbce5f55
Author: Greg Hudson <ghudson at mit.edu>
Date:   Mon May 2 12:51:03 2016 -0400

    Fix cstyle-file.py when emacs is not installed
    
    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 |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/src/util/cstyle-file.py b/src/util/cstyle-file.py
index a080fef..7e90b66 100644
--- a/src/util/cstyle-file.py
+++ b/src/util/cstyle-file.py
@@ -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()


More information about the cvs-krb5 mailing list