Skip to content

tkinter.filedialog.askopenfilename raises TypeError when filetypes=None #143526

@windymilla

Description

@windymilla

Bug report

Bug description:

tkinter.filedialog.askopenfilename raises TypeError when filetypes=None, despite docs stating that None is acceptable.

Expected behavior:

Passing filetypes=None should behave the same as omitting the option and open the file dialog without restricting file types.

Actual behavior:

A TypeError: 'NoneType' object is not iterable exception is raised before the dialog is shown.

Root cause:

In Lib/tkinter/filedialog.py:

self.options["filetypes"] = tuple(self.options["filetypes"])

with no guard for None

Minimal example:

from tkinter import Tk, filedialog

root = Tk()
root.withdraw()

filedialog.askopenfilename(filetypes=None)

Python Versions: 3.14.0rc3 and 3.14.2

OS: Windows 11

CPython versions tested on:

3.14

Operating systems tested on:

Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytopic-tkinter

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions