[gnome-code-assistance] python: fix crash when pylint is not available



commit cd0f439a2cb67a1f7f0a6f468c33db5731321402
Author: Christian Hergert <christian hergert me>
Date:   Sun Feb 21 17:11:10 2016 -0800

    python: fix crash when pylint is not available
    
    If the client suggests the use of pylint using {"pylint":True}, then make
    sure that we have pylint available before calling into the linter module.

 backends/python/__init__.py |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/backends/python/__init__.py b/backends/python/__init__.py
index 9476d6f..8dc2cf2 100644
--- a/backends/python/__init__.py
+++ b/backends/python/__init__.py
@@ -24,8 +24,9 @@ import re
 try:
     from pylint import lint
     from pylint.reporters.text import TextReporter
+    HAS_PYLINT = True
 except ImportError:
-    pass
+    HAS_PYLINT = False
 
 from gnome.codeassistance import transport, types
 
@@ -97,7 +98,7 @@ class Service(transport.Service):
             # PEP8 is not installed. Do nothing.
             pass
 
-        if "pylint" in options and options["pylint"]:
+        if HAS_PYLINT and "pylint" in options and options["pylint"]:
             pylint = PyLint(doc.data_path)
             diagnostics = pylint.run()
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]