obj = self.context.namespace[node.id]
anno.setanno(node, 'live_val', obj)
if hasattr(obj, '__name__'):
+ anno.setanno(node, 'fqn', (obj.__name__,))
+ elif hasattr(obj, '__class__'):
+ obj_class = obj.__class__
+ anno.setanno(node, 'fqn',
+ (obj_class.__module__, obj_class.__name__))
+ else:
# If the symbol value is for example a primitive, then it will not
# have a name.
- anno.setanno(node, 'fqn', (obj.__name__,))
+ pass
else:
pass
# TODO(mdan): Should we raise an error here?
from __future__ import division
from __future__ import print_function
+import six
+
from tensorflow.contrib.autograph.pyct import anno
from tensorflow.contrib.autograph.pyct import context
from tensorflow.contrib.autograph.pyct import parser
node = self._parse_and_analyze(test_fn, {'a': True})
retval_node = node.body[0].body[0].value
- self.assertFalse(anno.hasanno(retval_node, 'fqn'))
+ if six.PY2:
+ self.assertEqual(
+ anno.getanno(retval_node, 'fqn'), ('__builtin__', 'bool'))
+ else:
+ self.assertEqual(anno.getanno(retval_node, 'fqn'), ('builtins', 'bool'))
def test_namespace(self):