'Look up the registered type for global value *gv*.'

def _lookup_global(self, gv):

    try:
        gv = weakref.ref(gv)
    except TypeError:
        pass
    try:
        return self._globals.get(gv, None)
    except TypeError:
        return None
