diff --git a/lib/bb/codeparser.py b/lib/bb/codeparser.py
index d249af326..7f6adaf36 100644
--- a/lib/bb/codeparser.py
+++ b/lib/bb/codeparser.py
@@ -72,15 +72,21 @@ def add_module_functions(fn, functions, namespace):
             parser.parse_python(None, filename=fn, lineno=1, fixedhash=fixedhash+f)
             #bb.warn("Cached %s" % f)
         except KeyError:
-            targetfn = inspect.getsourcefile(functions[f])
-            if fn != targetfn:
-                # Skip references to other modules outside this file
-                #bb.warn("Skipping %s" % name)
+            try:
+                targetfn = inspect.getsourcefile(functions[f])
+                if fn != targetfn:
+                    # Skip references to other modules outside this file
+                    #bb.warn("Skipping %s" % name)
+                    continue
+                lines, lineno = inspect.getsourcelines(functions[f])
+                src = "".join(lines)
+                parser.parse_python(src, filename=fn, lineno=lineno, fixedhash=fixedhash+f)
+                #bb.warn("Not cached %s" % f)
+            except TypeError:
+                # Since Python inspect wont support special types
+                # Skip references of typing special forms, aliases and tuples
+                bb.warn("Skipping refs to %s : %s" % (f, type(functions[f]).__name__))
                 continue
-            lines, lineno = inspect.getsourcelines(functions[f])
-            src = "".join(lines)
-            parser.parse_python(src, filename=fn, lineno=lineno, fixedhash=fixedhash+f)
-            #bb.warn("Not cached %s" % f)
         execs = parser.execs.copy()
         # Expand internal module exec references
         for e in parser.execs:
