Skip to content

Bug: secure-tempfile uses mkstemp which is not drop-in replaceable for mktemp #560

@drdavella

Description

@drdavella

The return value of mktemp is a single string representing the filename, whereas mkstemp returns a tuple of an open OS file handle and the filename. See the docs.

A simple solution would be to replace the call like this:

-filename = tempfile.mktemp()
+filename = tempfile.mkstemp()[1]

However, that leaks the file handle in the first argument of the tuple, which needs to be closed.

A better solution might be to use TemporaryFile. However, that is also not API-compatible with mktemp.

In either case we need a more sophisticated solution.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions