From 2a87af062b79d914ce0120f1f1763213c1ebe8c4 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) 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 e717222cf98b..d6ac4b3e0b67 100644 --- a/Lib/concurrent/futures/__init__.py +++ b/Lib/concurrent/futures/__init__.py @@ -44,7 +44,7 @@ if _interpreters: 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 f35b11943082..8ded9f992483 100644 --- a/Lib/test/test___all__.py +++ b/Lib/test/test___all__.py @@ -72,6 +72,8 @@ class AllTest(unittest.TestCase): 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 000000000000..78f169ea029b --- /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`. -- 2.47.3