Skip to content

Replaced redundant mktemp() with mkstemp() #1754

Merged
davidism merged 2 commits into
pallets:masterfrom
MIS-Alex:mkstemp
Jan 14, 2021
Merged

Replaced redundant mktemp() with mkstemp() #1754
davidism merged 2 commits into
pallets:masterfrom
MIS-Alex:mkstemp

Conversation

@MIS-Alex

Copy link
Copy Markdown
Contributor

Replaced redundant function with the recommended alternative.

Checklist:

  • Add an entry in CHANGES.rst summarizing the change and linking to the issue.
  • Run pre-commit hooks and fix any issues.

@davidism
davidism merged commit 2fc486c into pallets:master Jan 14, 2021
@davidism davidism added this to the 8.0.0 milestone Jan 14, 2021
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Jan 29, 2021
Comment thread src/click/_termui_impl.py
import tempfile

filename = tempfile.mktemp()
filename = tempfile.mkstemp()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look correct. mkstemp returns a tuple, but below we use filename as if it was a string filename...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also further below, shouldn't we use subprocess.call() instead of os.system()? I don't think you can put anything nasty in the temp filename, but I think it'd also fail in other cases like cmd containing a space..

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Treating the return as a tuple was fixed later. Using subprocess.call is an open issue #1476, I need to test things like this before I merge it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use of deprecated & insecure tempfile.mktemp()

3 participants