Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Lib/concurrent/futures/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,13 @@
__all__.append('InterpreterPoolExecutor')


# Set __module__ to the public location rather than the private _base module.
Future.__module__ = 'concurrent.futures'
Executor.__module__ = 'concurrent.futures'
CancelledError.__module__ = 'concurrent.futures'
InvalidStateError.__module__ = 'concurrent.futures'
BrokenExecutor.__module__ = 'concurrent.futures'


def __dir__():
return __all__ + ['__author__', '__doc__']
14 changes: 14 additions & 0 deletions Lib/test/test_concurrent_futures/test_future.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,20 @@ def test_repr(self):
repr(SUCCESSFUL_FUTURE),
'<Future at 0x[0-9a-f]+ state=finished returned int>')

def test_class_str(self):
self.assertEqual(str(futures.Future),
"<class 'concurrent.futures.Future'>")
self.assertEqual(str(futures.CancelledError),
"<class 'concurrent.futures.CancelledError'>")
self.assertEqual(str(futures.TimeoutError),
"<class 'TimeoutError'>")
self.assertEqual(str(futures.Executor),
"<class 'concurrent.futures.Executor'>")
self.assertEqual(str(futures.InvalidStateError),
"<class 'concurrent.futures.InvalidStateError'>")
self.assertEqual(str(futures.BrokenExecutor),
"<class 'concurrent.futures.BrokenExecutor'>")

def test_cancel(self):
f1 = create_future(state=PENDING)
f2 = create_future(state=RUNNING)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Set ``__module__`` to ``concurrent.futures`` on the public classes
``Future``, ``Executor``, ``CancelledError``, ``InvalidStateError`` and
``BrokenExecutor``, so their ``repr`` and exception tracebacks reference the
documented public location rather than the private ``concurrent.futures._base``
module.
Loading