Use `tempfile.mkstemp` instead of `tempfile.mktemp`.
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: 420359224
Change-Id: I7bfc1df9cf931f45ec85d4878874ef41b9c55474
diff --git a/tensorflow/python/debug/cli/readline_ui_test.py b/tensorflow/python/debug/cli/readline_ui_test.py
index 4d3c3c3..fa37a64 100644
--- a/tensorflow/python/debug/cli/readline_ui_test.py
+++ b/tensorflow/python/debug/cli/readline_ui_test.py
@@ -31,9 +31,11 @@
"""Test subclass of ReadlineUI that bypasses terminal manipulations."""
def __init__(self, on_ui_exit=None, command_sequence=None):
+ _, config_file_path = tempfile.mkstemp() # safe to ignore fd
readline_ui.ReadlineUI.__init__(
- self, on_ui_exit=on_ui_exit,
- config=cli_config.CLIConfig(config_file_path=tempfile.mktemp()))
+ self,
+ on_ui_exit=on_ui_exit,
+ config=cli_config.CLIConfig(config_file_path=config_file_path))
self._command_sequence = command_sequence
self._command_counter = 0
@@ -164,7 +166,7 @@
self.assertTrue(observer["callback_invoked"])
def testIncompleteRedirectWorks(self):
- output_path = tempfile.mktemp()
+ _, output_path = tempfile.mkstemp() # safe to ignore fd
ui = MockReadlineUI(
command_sequence=["babble -n 2 > %s" % output_path, "exit"])