Fix some tensorflow errors triggered when tests are run with python3 -bb.
PiperOrigin-RevId: 294716915 Change-Id: I725b900eb0da80ea8693f23491b0171dc11affe6
This commit is contained in:
parent
3bc8e7e0e7
commit
34f38875b1
tensorflow/python
@ -539,10 +539,10 @@ class _EagerDefinedFunction(object):
|
||||
if not g and context.executing_eagerly():
|
||||
context.context().add_function_def(self.definition)
|
||||
else:
|
||||
if self.name not in g._functions:
|
||||
if not g._is_function(self.name):
|
||||
g._add_function(self)
|
||||
for f in self.graph._functions.values():
|
||||
if f.name not in g._functions:
|
||||
if not g._is_function(f.name):
|
||||
g._add_function(f)
|
||||
# pylint: enable=protected-access
|
||||
|
||||
|
@ -222,7 +222,7 @@ def get_timestamped_export_dir(export_dir_base):
|
||||
time.sleep(1)
|
||||
attempts += 1
|
||||
logging.warn('Directory {} already exists; retrying (attempt {}/{})'.format(
|
||||
result_dir, attempts, MAX_DIRECTORY_CREATION_ATTEMPTS))
|
||||
compat.as_str(result_dir), attempts, MAX_DIRECTORY_CREATION_ATTEMPTS))
|
||||
raise RuntimeError('Failed to obtain a unique export directory name after '
|
||||
'{} attempts.'.format(MAX_DIRECTORY_CREATION_ATTEMPTS))
|
||||
|
||||
|
@ -1144,6 +1144,7 @@ class Saver(object):
|
||||
if os.path.split(latest_filename)[0]:
|
||||
raise ValueError("'latest_filename' must not contain path components")
|
||||
|
||||
save_path = compat.as_str(save_path)
|
||||
if global_step is not None:
|
||||
if not isinstance(global_step, compat.integral_types):
|
||||
global_step = training_util.global_step(sess, global_step)
|
||||
|
@ -111,15 +111,15 @@ def as_text(bytes_or_text, encoding='utf-8'):
|
||||
raise TypeError('Expected binary or unicode string, got %r' % bytes_or_text)
|
||||
|
||||
|
||||
# Convert an object to a `str` in both Python 2 and 3.
|
||||
if _six.PY2:
|
||||
as_str = as_bytes
|
||||
tf_export('compat.as_bytes', 'compat.as_str')(as_bytes)
|
||||
tf_export('compat.as_text')(as_text)
|
||||
else:
|
||||
as_str = as_text
|
||||
tf_export('compat.as_bytes')(as_bytes)
|
||||
tf_export('compat.as_text', 'compat.as_str')(as_text)
|
||||
def as_str(bytes_or_text, encoding='utf-8'):
|
||||
if _six.PY2:
|
||||
return as_bytes(bytes_or_text, encoding)
|
||||
else:
|
||||
return as_text(bytes_or_text, encoding)
|
||||
|
||||
tf_export('compat.as_text')(as_text)
|
||||
tf_export('compat.as_bytes')(as_bytes)
|
||||
tf_export('compat.as_str')(as_str)
|
||||
|
||||
|
||||
@tf_export('compat.as_str_any')
|
||||
|
Loading…
Reference in New Issue
Block a user