aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/python/autograph/pyct/static_analysis/live_values.py
diff options
context:
space:
mode:
authorGravatar Dan Moldovan <mdan@google.com>2018-09-20 14:11:39 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-09-20 14:16:11 -0700
commitc07dc66e441c66a7cb1b136b4239e4dfdf84d221 (patch)
tree4c8a12301fc5481c15c41c22991e0bb51dfa39bc /tensorflow/python/autograph/pyct/static_analysis/live_values.py
parent17dbe77f5ad47e8fd71924f12b3bc53c05afbacf (diff)
Include the print function in the list of special functions - its name is not found in the namespace in Python 3.
PiperOrigin-RevId: 213879813
Diffstat (limited to 'tensorflow/python/autograph/pyct/static_analysis/live_values.py')
-rw-r--r--tensorflow/python/autograph/pyct/static_analysis/live_values.py9
1 files changed, 6 insertions, 3 deletions
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?