Skip to content

Commit ccf7225

Browse files
committed
Ensure that concurrent.future.Future has the right module name (e.g. in exceptions)
1 parent d909733 commit ccf7225

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

Lib/concurrent/futures/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@
3333
)
3434

3535

36+
# Remove the _base name from the exposed module.
37+
Future.__module__ = CancelledError.__module__ = Executor.__module__ = (
38+
'concurrent.futures'
39+
)
40+
41+
3642
def __dir__():
3743
return __all__ + ('__author__', '__doc__')
3844

Lib/test/test_concurrent_futures/test_future.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,16 @@ def test_repr(self):
134134
repr(SUCCESSFUL_FUTURE),
135135
'<Future at 0x[0-9a-f]+ state=finished returned int>')
136136

137+
def test_class_str(self):
138+
self.assertEqual(str(futures.Future),
139+
"<class 'concurrent.futures.Future'>")
140+
self.assertEqual(str(futures.CancelledError),
141+
"<class 'concurrent.futures.CancelledError'>")
142+
self.assertEqual(str(futures.TimeoutError),
143+
"<class 'TimeoutError'>")
144+
self.assertEqual(str(futures.Executor),
145+
"<class 'concurrent.futures.Executor'>")
146+
137147
def test_cancel(self):
138148
f1 = create_future(state=PENDING)
139149
f2 = create_future(state=RUNNING)

0 commit comments

Comments
 (0)