Skip to content

Remove tempfile.mktemp() #80490

Closed as not planned
Closed as not planned

Description

@johnthagen
BPO 36309
Nosy @brettcannon, @serhiy-storchaka, @matrixise, @johnthagen, @pablogsal
PRs
  • bpo-36309: Raise a PendingDeprecationWarning when calling tempfile.mktemp() #12437
  • bpo-36309 pydoc.py: line 1533 - updated mktemp to mkstemp #15640
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = None
    created_at = <Date 2019-03-16.00:49:04.986>
    labels = ['3.8', 'type-feature', 'library']
    title = 'Remove tempfile.mktemp()'
    updated_at = <Date 2019-09-02.10:24:19.820>
    user = 'https://github.com/johnthagen'

    bugs.python.org fields:

    activity = <Date 2019-09-02.10:24:19.820>
    actor = 'python-dev'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2019-03-16.00:49:04.986>
    creator = 'John Hagen'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 36309
    keywords = ['patch']
    message_count = 6.0
    messages = ['338046', '338302', '338304', '338305', '338324', '338348']
    nosy_count = 5.0
    nosy_names = ['brett.cannon', 'serhiy.storchaka', 'matrixise', 'John Hagen', 'pablogsal']
    pr_nums = ['12437', '15640']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue36309'
    versions = ['Python 3.8']

    Linked PRs

    Activity

    1. johnthagen commented on Mar 16, 2019

      johnthagenmannequin
      MannequinAuthor

      tempfile.mktemp has been deprecated since Python 2.3 and has security concerns attached to it. Is it time that this is finally removed?

      https://docs.python.org/3/library/tempfile.html#tempfile.mktemp

    2. added
      3.8 (EOL)
      stdlib
      type-feature
      on Mar 16, 2019
    3. brettcannon commented on Mar 19, 2019

      @brettcannon
      Member

      Unfortunately not because there is no warning being raised currently about the deprecation (it's only documented as deprecated; 44f602d). A PR raising an appropriate deprecation for at least one release would then allow us to consider removing it in subsequent release.

    4. pablogsal commented on Mar 19, 2019

      @pablogsal
      Member

      There was a warning, but it was suppressed by this commit:

      commit 44f602d
      Author: Guido van Rossum <[email protected]>
      Date: Fri Nov 22 15:56:29 2002 +0000

      Comment out the warnings about mktemp().  These are too annoying, and
      often unavoidable.
      

      diff --git a/Lib/tempfile.py b/Lib/tempfile.py
      index 97f125250b..0393ba5d30 100644
      --- a/Lib/tempfile.py
      +++ b/Lib/tempfile.py
      @@ -324,9 +324,9 @@ def mktemp(suffix="", prefix=template, dir=None):
      the punch.
      """

      -    from warnings import warn as _warn
      -    _warn("mktemp is a potential security risk to your program",
      -          RuntimeWarning, stacklevel=2)
      +##    from warnings import warn as _warn
      +##    _warn("mktemp is a potential security risk to your program",
      +##          RuntimeWarning, stacklevel=2)
           if dir is None:
               dir = gettempdir()
    5. johnthagen commented on Mar 19, 2019

      johnthagenmannequin
      MannequinAuthor

      Should it be a DeprecationWarning instead of a RuntimeWarning? (or both since it's both deprecated and a security issue?)

    6. serhiy-storchaka commented on Mar 19, 2019

      @serhiy-storchaka
      Member

      Taking to the account the widespread use of mktemp(), I think it needs more than one release for deprecation.

      This should be discussed on the Python-Dev mailing list first.

    7. transferred this issue fromon Apr 10, 2022
    8. added a commit that references this issue on Nov 6, 2023
    9. vstinner commented on Sep 11, 2024

      @vstinner
      Member

      I don't think that we should remove this function. It's deprecated and its documentation contains a big red warning about security. IMO it's enough: https://docs.python.org/dev/library/tempfile.html#tempfile.mktemp I close the issue as WONT FIX.

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

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      3.8 (EOL)stdlibtype-feature

      Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions