=== modified file '.pc/applied-patches'
--- .pc/applied-patches	2014-01-04 12:14:12 +0000
+++ .pc/applied-patches	2014-04-11 15:21:41 +0000
@@ -0,0 +1,1 @@
+git_fa1312a4d7aa.patch

=== added directory '.pc/git_fa1312a4d7aa.patch'
=== added file '.pc/git_fa1312a4d7aa.patch/.timestamp'
=== added directory '.pc/git_fa1312a4d7aa.patch/brain'
=== added file '.pc/git_fa1312a4d7aa.patch/brain/py2gi.py'
--- .pc/git_fa1312a4d7aa.patch/brain/py2gi.py	1970-01-01 00:00:00 +0000
+++ .pc/git_fa1312a4d7aa.patch/brain/py2gi.py	2014-04-11 15:21:41 +0000
@@ -0,0 +1,147 @@
+"""Astroid hooks for the Python 2 GObject introspection bindings.
+
+Helps with understanding everything imported from 'gi.repository'
+"""
+
+import inspect
+import sys
+
+from astroid import MANAGER, AstroidBuildingException
+from astroid.builder import AstroidBuilder
+
+
+_inspected_modules = {}
+
+
+def _gi_build_stub(parent):
+    """
+    Inspect the passed module recursively and build stubs for functions,
+    classes, etc.
+    """
+    classes = {}
+    functions = {}
+    constants = {}
+    methods = {}
+    for name in dir(parent):
+        if not name or name.startswith("__"):
+            # GLib.IConv has a parameter named "" :/
+            continue
+        try:
+            obj = getattr(parent, name)
+        except:
+            continue
+
+        if inspect.isclass(obj):
+            classes[name] = obj
+        elif (inspect.isfunction(obj) or
+              inspect.isbuiltin(obj)):
+            functions[name] = obj
+        elif (inspect.ismethod(obj) or
+              inspect.ismethoddescriptor(obj)):
+            methods[name] = obj
+        elif type(obj) in [int, str]:
+            constants[name] = obj
+        elif (str(obj).startswith("<flags") or
+              str(obj).startswith("<enum ") or
+              str(obj).startswith("<GType ") or
+              inspect.isdatadescriptor(obj)):
+            constants[name] = 0
+
+    ret = ""
+
+    if constants:
+        ret += "# %s contants\n\n" % parent.__name__
+    for name in sorted(constants):
+        if name[0].isdigit():
+            # GDK has some busted constant names like
+            # Gdk.EventType.2BUTTON_PRESS
+            continue
+
+        val = constants[name]
+
+        strval = str(val)
+        if type(val) is str:
+            strval = '"%s"' % str(val).replace("\\", "\\\\")
+        ret += "%s = %s\n" % (name, strval)
+
+    if ret:
+        ret += "\n\n"
+    if functions:
+        ret += "# %s functions\n\n" % parent.__name__
+    for name in sorted(functions):
+        func = functions[name]
+        ret += "def %s(*args, **kwargs):\n" % name
+        ret += "    pass\n"
+
+    if ret:
+        ret += "\n\n"
+    if methods:
+        ret += "# %s methods\n\n" % parent.__name__
+    for name in sorted(methods):
+        func = methods[name]
+        ret += "def %s(self, *args, **kwargs):\n" % name
+        ret += "    pass\n"
+
+    if ret:
+        ret += "\n\n"
+    if classes:
+        ret += "# %s classes\n\n" % parent.__name__
+    for name in sorted(classes):
+        ret += "class %s(object):\n" % name
+
+        classret = _gi_build_stub(classes[name])
+        if not classret:
+            classret = "pass\n"
+
+        for line in classret.splitlines():
+            ret += "    " + line + "\n"
+        ret += "\n"
+
+    return ret
+
+# Overwrite Module.module_import to _actually_ import the introspected module if
+# it's a gi module, then build stub code by examining its info and get an astng
+# from that
+
+from astroid.scoped_nodes import Module
+_orig_import_module = Module.import_module
+
+def _new_import_module(self, modname, relative_only=False, level=None):
+    # Could be a static piece of gi.repository or whatever unrelated module,
+    # let that fall through
+    try:
+        return _orig_import_module(self, modname, relative_only, level)
+    except AstroidBuildingException:
+        # we only consider gi.repository submodules
+        if not modname.startswith('gi.repository.'):
+            if relative_only and level is None:
+                level = 0
+            modname = self.relative_to_absolute_name(modname, level)
+        if not modname.startswith('gi.repository.'):
+            raise
+    # build astroid representation unless we already tried so
+    if modname not in _inspected_modules:
+        modnames = [modname]
+        # GLib and GObject have some special case handling
+        # in pygobject that we need to cope with
+        if modname == 'gi.repository.GLib':
+            modnames.append('gi._glib')
+        elif modname == 'gi.repository.GObject':
+            modnames.append('gi._gobject')
+        try:
+            modcode = ''
+            for m in modnames:
+                __import__(m)
+                modcode += _gi_build_stub(sys.modules[m])
+        except ImportError:
+            astng = _inspected_modules[modname] = None
+        else:
+            astng = AstroidBuilder(MANAGER).string_build(modcode, modname)
+            _inspected_modules[modname] = astng
+    else:
+        astng = _inspected_modules[modname]
+    if astng is None:
+        raise AstroidBuildingException('Failed to import module %r' % modname)
+    return astng
+
+Module.import_module = _new_import_module

=== modified file 'brain/py2gi.py'
--- brain/py2gi.py	2014-01-04 12:14:12 +0000
+++ brain/py2gi.py	2014-04-11 15:21:41 +0000
@@ -5,6 +5,7 @@
 
 import inspect
 import sys
+import re
 
 from astroid import MANAGER, AstroidBuildingException
 from astroid.builder import AstroidBuilder
@@ -12,6 +13,7 @@
 
 _inspected_modules = {}
 
+_identifier_re = r'^[A-Za-z_]\w*$'
 
 def _gi_build_stub(parent):
     """
@@ -23,9 +25,13 @@
     constants = {}
     methods = {}
     for name in dir(parent):
-        if not name or name.startswith("__"):
-            # GLib.IConv has a parameter named "" :/
-            continue
+        if name.startswith("__"):
+            continue
+
+        # Check if this is a valid name in python
+        if not re.match(_identifier_re, name):
+            continue
+
         try:
             obj = getattr(parent, name)
         except:
@@ -46,6 +52,12 @@
               str(obj).startswith("<GType ") or
               inspect.isdatadescriptor(obj)):
             constants[name] = 0
+        elif callable(obj):
+            # Fall back to a function for anything callable
+            functions[name] = obj
+        else:
+            # Assume everything else is some manner of constant
+            constants[name] = 0
 
     ret = ""
 

=== modified file 'debian/changelog'
--- debian/changelog	2014-01-04 12:14:12 +0000
+++ debian/changelog	2014-04-11 15:21:41 +0000
@@ -1,3 +1,10 @@
+astroid (1.0.1-1ubuntu1) trusty; urgency=medium
+
+  * debian/patch/git_fa1312a4d7aa.patch
+    + fix gi instrospections issues (lp: #1306674)
+
+ -- Leo Iannacone <l3on@ubuntu.com>  Fri, 11 Apr 2014 17:15:12 +0200
+
 astroid (1.0.1-1) unstable; urgency=low
 
   * Initial release (Closes: #734075)

=== modified file 'debian/control'
--- debian/control	2014-01-04 12:14:12 +0000
+++ debian/control	2014-04-11 15:21:41 +0000
@@ -1,7 +1,8 @@
 Source: astroid
 Section: python
 Priority: optional
-Maintainer: Debian Python Modules Team <python-modules-team@lists.alioth.debian.org>
+Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
+XSBC-Original-Maintainer: Debian Python Modules Team <python-modules-team@lists.alioth.debian.org>
 Uploaders: Sandro Tosi <morph@debian.org>
 Build-Depends: debhelper (>= 9.0.0), python, python3
 Standards-Version: 3.9.5

=== added directory 'debian/patches'
=== added file 'debian/patches/git_fa1312a4d7aa.patch'
--- debian/patches/git_fa1312a4d7aa.patch	1970-01-01 00:00:00 +0000
+++ debian/patches/git_fa1312a4d7aa.patch	2014-04-11 15:21:41 +0000
@@ -0,0 +1,57 @@
+From: User Sylvain Thénault <sylvain.thenault@logilab.fr>
+Subject: backport gi related changes from pylint-brain
+Origin: upstream, https://bitbucket.org/logilab/astroid/commits/fa1312a4d7aa
+
+Bug: https://bitbucket.org/logilab/astroid/issue/22/patch-brain-pygi-fix-function-inspection
+Bug: https://bitbucket.org/logilab/astroid/issue/19/syntaxerror-when-examining-gi-modules
+Bug-Debian: http://bugs.debian.org/744225 
+Bug-Ubuntu: https://bugs.launchpad.net/bugs/1306674 
+
+diff --git a/brain/py2gi.py b/brain/py2gi.py
+--- a/brain/py2gi.py
++++ b/brain/py2gi.py
+@@ -5,6 +5,7 @@
+ 
+ import inspect
+ import sys
++import re
+ 
+ from astroid import MANAGER, AstroidBuildingException
+ from astroid.builder import AstroidBuilder
+@@ -12,6 +13,7 @@
+ 
+ _inspected_modules = {}
+ 
++_identifier_re = r'^[A-Za-z_]\w*$'
+ 
+ def _gi_build_stub(parent):
+     """
+@@ -23,9 +25,13 @@
+     constants = {}
+     methods = {}
+     for name in dir(parent):
+-        if not name or name.startswith("__"):
+-            # GLib.IConv has a parameter named "" :/
++        if name.startswith("__"):
+             continue
++
++        # Check if this is a valid name in python
++        if not re.match(_identifier_re, name):
++            continue
++
+         try:
+             obj = getattr(parent, name)
+         except:
+@@ -46,6 +52,12 @@
+               str(obj).startswith("<GType ") or
+               inspect.isdatadescriptor(obj)):
+             constants[name] = 0
++        elif callable(obj):
++            # Fall back to a function for anything callable
++            functions[name] = obj
++        else:
++            # Assume everything else is some manner of constant
++            constants[name] = 0
+ 
+     ret = ""
+ 

=== added file 'debian/patches/series'
--- debian/patches/series	1970-01-01 00:00:00 +0000
+++ debian/patches/series	2014-04-11 15:21:41 +0000
@@ -0,0 +1,1 @@
+git_fa1312a4d7aa.patch

