Skip to content

Commit

Permalink
Use mkstemp unconditionally. mktemp has been deprecated since Python …
Browse files Browse the repository at this point in the history
…2.3.
  • Loading branch information
jaraco committed May 29, 2024
1 parent e5b06e1 commit 4549de1
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions distutils/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import subprocess
import sys
import sysconfig
import tempfile

from ._log import log
from ._modified import newer
Expand Down Expand Up @@ -405,20 +406,10 @@ def byte_compile( # noqa: C901
# "Indirect" byte-compilation: write a temporary script and then
# run it with the appropriate flags.
if not direct:
try:
from tempfile import mkstemp

(script_fd, script_name) = mkstemp(".py")
except ImportError:
from tempfile import mktemp

(script_fd, script_name) = None, mktemp(".py")
(script_fd, script_name) = tempfile.mkstemp(".py")
log.info("writing byte-compilation script '%s'", script_name)
if not dry_run:
if script_fd is not None:
script = os.fdopen(script_fd, "w", encoding='utf-8')
else: # pragma: no cover
script = open(script_name, "w", encoding='utf-8')
script = os.fdopen(script_fd, "w", encoding='utf-8')

with script:
script.write(
Expand Down

0 comments on commit 4549de1

Please sign in to comment.