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: 420363556
Change-Id: I3225120cd6545462174641581a365ead0eb179c3
  • Loading branch information
mihaimaruseac authored and tensorflower-gardener committed Jan 7, 2022
1 parent 247aaaf commit b2fec2d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tensorflow/python/saved_model/load_test.py
Expand Up @@ -207,8 +207,8 @@ def test_control_outputs(self, cycles):
imported_graph.control_outputs)

def _make_asset(self, contents):
filename = tempfile.mktemp(prefix=self.get_temp_dir())
with open(filename, "w") as f:
fd, filename = tempfile.mkstemp(prefix=self.get_temp_dir())
with os.fdopen(fd, "w") as f:
f.write(contents)
return filename

Expand Down Expand Up @@ -2494,8 +2494,8 @@ def layer_variable_creator(next_creator, **kwargs):
load_and_run_module(export_dir, weight_size)

def _make_asset(self, contents):
filename = tempfile.mktemp(prefix=self.get_temp_dir())
with open(filename, "w") as f:
fd, filename = tempfile.mkstemp(prefix=self.get_temp_dir())
with os.fdopen(fd, "w") as f:
f.write(contents)
return filename

Expand Down

0 comments on commit b2fec2d

Please sign in to comment.