From 5a93bb319c3672e9d6fe604e3611095116cb5fcc Mon Sep 17 00:00:00 2001 From: James Ring Date: Tue, 16 Apr 2019 16:05:03 -0700 Subject: [PATCH] Remove certain symbols from tensorflow.__all__. When deleting `compiler`, `core` and `python` symbols from `tensorflow`, we currently don't remove them from `__all__`. This breaks anybody who tries to do `from tensorflow import *`. PiperOrigin-RevId: 243897920 --- tensorflow/api_template_v1.__init__.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tensorflow/api_template_v1.__init__.py b/tensorflow/api_template_v1.__init__.py index 8dd14568fe3..c5ba4e208a4 100644 --- a/tensorflow/api_template_v1.__init__.py +++ b/tensorflow/api_template_v1.__init__.py @@ -118,7 +118,11 @@ if _running_from_pip_package(): # pylint: disable=undefined-variable try: del python + if '__all__' in vars(): + vars()['__all__'].remove('python') del core + if '__all__' in vars(): + vars()['__all__'].remove('core') except NameError: # Don't fail if these modules are not available. # For e.g. this file will be originally placed under tensorflow/_api/v1 which @@ -129,6 +133,8 @@ except NameError: # others don't exist. try: del compiler + if '__all__' in vars(): + vars()['__all__'].remove('compiler') except NameError: pass # pylint: enable=undefined-variable