[gobject-introspection] scanner: Explicitly error with constructors but no GObject include



commit 415895066f3395a4c6b6e7ab1cfe6674d962d469
Author: Colin Walters <walters verbum org>
Date:   Tue Sep 29 10:59:24 2015 -0400

    scanner: Explicitly error with constructors but no GObject include
    
    One of the Anaconda developers hit this; the fix was to include
    GObject, but without this commit we just traceback'd.

 giscanner/maintransformer.py |    6 +++++-
 giscanner/message.py         |    2 ++
 2 files changed, 7 insertions(+), 1 deletions(-)
---
diff --git a/giscanner/maintransformer.py b/giscanner/maintransformer.py
index 1b413ed..2871aba 100644
--- a/giscanner/maintransformer.py
+++ b/giscanner/maintransformer.py
@@ -508,7 +508,11 @@ class MainTransformer(object):
         elif isinstance(parent, ast.Function) and parent.is_constructor:
             if isinstance(target, ast.Class):
                 initially_unowned_type = ast.Type(target_giname='GObject.InitiallyUnowned')
-                initially_unowned = self._transformer.lookup_typenode(initially_unowned_type)
+                try:
+                    initially_unowned = self._transformer.lookup_typenode(initially_unowned_type)
+                except KeyError as e:
+                    message.error_node(node, "constructor found but GObject is not in includes")
+                    return None
                 if initially_unowned and self._is_gi_subclass(typeval, initially_unowned_type):
                     return ast.PARAM_TRANSFER_NONE
                 else:
diff --git a/giscanner/message.py b/giscanner/message.py
index 6392dfc..a6bdfaa 100644
--- a/giscanner/message.py
+++ b/giscanner/message.py
@@ -190,6 +190,8 @@ def warn(text, positions=None, prefix=None, marker_pos=None, marker_line=None):
 def warn_node(node, text, context=None, positions=None):
     log_node(WARNING, node, text, context=context, positions=positions)
 
+def error_node(node, text, context=None, positions=None):
+    log_node(ERROR, node, text, context=context, positions=positions)
 
 def warn_symbol(symbol, text):
     ml = MessageLogger.get()


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