From c07dc66e441c66a7cb1b136b4239e4dfdf84d221 Mon Sep 17 00:00:00 2001 From: Dan Moldovan Date: Thu, 20 Sep 2018 14:11:39 -0700 Subject: Include the print function in the list of special functions - its name is not found in the namespace in Python 3. PiperOrigin-RevId: 213879813 --- tensorflow/python/autograph/pyct/static_analysis/live_values.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'tensorflow/python/autograph/pyct/static_analysis/live_values.py') diff --git a/tensorflow/python/autograph/pyct/static_analysis/live_values.py b/tensorflow/python/autograph/pyct/static_analysis/live_values.py index 48b442f3bd..3963772dad 100644 --- a/tensorflow/python/autograph/pyct/static_analysis/live_values.py +++ b/tensorflow/python/autograph/pyct/static_analysis/live_values.py @@ -29,10 +29,11 @@ from tensorflow.python.autograph.pyct import anno from tensorflow.python.autograph.pyct import transformer from tensorflow.python.autograph.pyct.static_analysis.annos import NodeAnno + # TODO(aqj): Do we need this? Do other builtins fail in similar ways # See b/114389775 for a related bug in pyct # These symbols are legal in Python, but don't appear in the namespace. -_special_symbols = {'range': range} +_SPECIAL_SYMBOLS = {'range': range, 'print': print} class LiveValueResolver(transformer.Base): @@ -71,8 +72,10 @@ class LiveValueResolver(transformer.Base): # If the symbol value is for example a primitive, then it will not # have a name. pass - elif node.id in _special_symbols: - anno.setanno(node, 'live_val', _special_symbols[node.id]) + elif node.id in _SPECIAL_SYMBOLS: + # Note: if the user redefined any of these symbols, then they would + # be visible in the namespace and we would never reach this branch. + anno.setanno(node, 'live_val', _SPECIAL_SYMBOLS[node.id]) else: pass # TODO(mdan): Should we raise an error here? -- cgit v1.2.3