Fixed Improper Method Call: Replaced `mktemp` (#1828)

* Replaced `mktemp` with `mkstemp`

Signed-off-by: fazledyn-or <ataf@openrefactory.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Signed-off-by: fazledyn-or <ataf@openrefactory.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Ataf Fazledin Ahamed 2023-12-06 18:41:13 +06:00 committed by GitHub
parent dfec2912e8
commit 3d6c6dd701
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -2,6 +2,7 @@
from __future__ import annotations
import os
import sys
from .encoding import default_encode
@ -10,13 +11,14 @@ from .encoding import default_encode
def emergency_dump_state(state, open_file=open, dump=None, stderr=None):
"""Dump message state to stdout or file."""
from pprint import pformat
from tempfile import mktemp
from tempfile import mkstemp
stderr = sys.stderr if stderr is None else stderr
if dump is None:
import pickle
dump = pickle.dump
persist = mktemp()
fd, persist = mkstemp()
os.close(fd)
print(f'EMERGENCY DUMP STATE TO FILE -> {persist} <-',
file=stderr)
fh = open_file(persist, 'w')