From c7b5f885745385c0992f75e4543a47ded3120c04 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Thu, 31 Jul 2025 12:17:27 -0400 Subject: [PATCH] gh-137282: Fix `TypeError` in tab completion and `dir()` of `concurrent.futures` (GH-137214) (cherry picked from commit 2a87af062b79d914ce0120f1f1763213c1ebe8c4) Co-authored-by: Henry Schreiner Signed-off-by: Henry Schreiner --- Lib/concurrent/futures/__init__.py | 2 +- Lib/test/test___all__.py | 2 ++ .../next/Library/2025-07-31-10-31-56.gh-issue-137282.GOCwIC.rst | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Library/2025-07-31-10-31-56.gh-issue-137282.GOCwIC.rst diff --git a/Lib/concurrent/futures/__init__.py b/Lib/concurrent/futures/__init__.py index e717222cf98b32..d6ac4b3e0b675f 100644 --- a/Lib/concurrent/futures/__init__.py +++ b/Lib/concurrent/futures/__init__.py @@ -44,7 +44,7 @@ def __dir__(): - return __all__ + ('__author__', '__doc__') + return __all__ + ['__author__', '__doc__'] def __getattr__(name): diff --git a/Lib/test/test___all__.py b/Lib/test/test___all__.py index f35b1194308262..8ded9f99248372 100644 --- a/Lib/test/test___all__.py +++ b/Lib/test/test___all__.py @@ -72,6 +72,8 @@ def check_all(self, modname): all_set = set(all_list) self.assertCountEqual(all_set, all_list, "in module {}".format(modname)) self.assertEqual(keys, all_set, "in module {}".format(modname)) + # Verify __dir__ is non-empty and doesn't produce an error + self.assertTrue(dir(sys.modules[modname])) def walk_modules(self, basedir, modpath): for fn in sorted(os.listdir(basedir)): diff --git a/Misc/NEWS.d/next/Library/2025-07-31-10-31-56.gh-issue-137282.GOCwIC.rst b/Misc/NEWS.d/next/Library/2025-07-31-10-31-56.gh-issue-137282.GOCwIC.rst new file mode 100644 index 00000000000000..78f169ea029b17 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2025-07-31-10-31-56.gh-issue-137282.GOCwIC.rst @@ -0,0 +1 @@ +Fix tab completion and :func:`dir` on :mod:`concurrent.futures`.