FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Deprecate tkinter.filedialog.askopenfiles() · Issue #152638 · python/cpython · GitHub

Repository navigation

Deprecate tkinter.filedialog.askopenfiles() #152638

Closed

Description

Feature or enhancement

tkinter.filedialog.askopenfiles() returns a list of already-open file objects, which is inherently unsafe:

  • If opening one of the files fails, the files already opened are leaked — there is no way to build the result without this risk.
  • A list of open files cannot be used in a with statement. The caller must iterate and close them, and on an exception in the loop must close both the already-processed and the not-yet-processed files, which is hard to get right.
  • The number of open file descriptors is limited, so opening all the files at once may not even be possible.

The safe and simple alternative is to iterate over the names returned by askopenfilenames() and open them one by one, ideally with a with statement.

Proposal: deprecate askopenfiles() in 3.16 and remove it in 3.18.

The single-file askopenfile() and asksaveasfile() are not affected — they return a single file object that the caller can use directly.

Linked PRs

Activity

  1. StanFromIreland commented on Jun 30, 2026

    Member

    Proposal: deprecate askopenfiles() in 3.16 and remove it in 3.18.

    Two years is quite short IMO, only 40% of PEP-387's recommended guideline.

  2. added
    stdlibStandard Library Python modules in the Lib/ directory
    on Jul 3, 2026
  3. added a commit that references this issue on Jul 5, 2026
  4. serhiy-storchaka commented on Jul 5, 2026

    MemberAuthor

    Good point. I've moved removal to 3.19, so the deprecation now spans three feature releases (3.16–3.18) before removal.

  5. added 3 commits that reference this issue on Jul 11, 2026
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

    stdlibStandard Library Python modules in the Lib/ directorytopic-tkintertype-featureA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL