Skip to content

Commit

Permalink
Use tempfile.mkstemp instead of tempfile.mktemp.
Browse files Browse the repository at this point in the history
The `tempfile.mktemp` function is [deprecated](https://docs.python.org/3/library/tempfile.html#tempfile.mktemp) due to [security issues](https://cwe.mitre.org/data/definitions/377.html).

The switch is easy to do.

PiperOrigin-RevId: 420359138
Change-Id: I8afc97448b1e730ac5883c2033f3b0e544b8fb58
  • Loading branch information
mihaimaruseac authored and tensorflower-gardener committed Jan 7, 2022
1 parent ca5fe92 commit 4b50e58
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions tensorflow/python/debug/examples/v1/debug_keras.py
Expand Up @@ -40,9 +40,11 @@ def main(_):
sess = tf.Session()
if FLAGS.debug:
# Use the command-line interface (CLI) of tfdbg.
config_file_path = (
tempfile.mktemp(".tfdbg_config")
if FLAGS.use_random_config_path else None)
if FLAGS.use_random_config_path:
# TODO(mihaimaruseac): Safe to ignore fd here?
_, config_file_path = tempfile.mkstemp(".tfdbg_config")
else:
config_file_path = None
sess = tf_debug.LocalCLIDebugWrapperSession(
sess, ui_type=FLAGS.ui_type, config_file_path=config_file_path)
elif FLAGS.tensorboard_debug_address:
Expand Down

0 comments on commit 4b50e58

Please sign in to comment.