[issue34344] Fix the docstring for AbstractEventLoopPolicy.get_event_loop
New submission from Vlad Starostin <drtyrsa@yandex.ru>: The docstring says "This may be None or an instance of EventLoop". But docs explicitly state that get_event_loop "must never return None". The same docstring is also in the example in docs: https://docs.python.org/3.6/library/asyncio-eventloops.html#customizing-the-... I propose changing it to: def get_event_loop(self): """Get the event loop. Returns an instance of EventLoop or raises an exception. """ If the wording is ok, I'll make a PR. ---------- assignee: docs@python components: Documentation, asyncio messages: 323190 nosy: asvetlov, docs@python, drtyrsa, yselivanov priority: normal severity: normal status: open title: Fix the docstring for AbstractEventLoopPolicy.get_event_loop versions: Python 3.6, Python 3.7, Python 3.8 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue34344> _______________________________________
Change by Karthikeyan Singaravelan <tir.karthi@gmail.com>: ---------- nosy: +xtreak _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue34344> _______________________________________
Karthikeyan Singaravelan <tir.karthi@gmail.com> added the comment: Thanks for the report. This looks like a valid change to me as I can see from the docstring it says it can be None but in the source code there is an explicit check that if self._local._loop which is returned is None then raise a RuntimeError. I would propose removing the docstring in the example. # Docstring says can be None ./python.exe -m pydoc asyncio.events.BaseDefaultEventLoopPolicy.get_event_loop | cat Help on function get_event_loop in asyncio.events.BaseDefaultEventLoopPolicy: asyncio.events.BaseDefaultEventLoopPolicy.get_event_loop = get_event_loop(self) Get the event loop. This may be None or an instance of EventLoop. # RuntimeError is raised for None ./python.exe -m inspect asyncio.events:BaseDefaultEventLoopPolicy.get_event_loop def get_event_loop(self): """Get the event loop. This may be None or an instance of EventLoop. """ if (self._local._loop is None and not self._local._set_called and isinstance(threading.current_thread(), threading._MainThread)): self.set_event_loop(self.new_event_loop()) if self._local._loop is None: raise RuntimeError('There is no current event loop in thread %r.' % threading.current_thread().name) return self._local._loop ---------- versions: +Python 3.9 -Python 3.6 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue34344> _______________________________________
Andrew Svetlov <andrew.svetlov@gmail.com> added the comment: Vlad, the PR is very welcome! ---------- _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue34344> _______________________________________
Change by Ido Michael <michael.ido@gmail.com>: ---------- keywords: +patch pull_requests: +16048 stage: -> patch review pull_request: https://github.com/python/cpython/pull/16463 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue34344> _______________________________________
Ido Michael <michael.ido@gmail.com> added the comment: I've fixed the documentation according to the thread. Here's the PR: GH-16463 Ido ---------- nosy: +Ido Michael _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue34344> _______________________________________
Yury Selivanov <yselivanov@gmail.com> added the comment: New changeset b23a8423a923077e4f83d3f328bb7542b4c940ed by Yury Selivanov (idomic) in branch 'master': bpo-34344 Fix AbstractEventLoopPolicy.get_event_loop docstring (GH-16463) https://github.com/python/cpython/commit/b23a8423a923077e4f83d3f328bb7542b4c... ---------- _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue34344> _______________________________________
Change by miss-islington <mariatta.wijaya+miss-islington@gmail.com>: ---------- pull_requests: +16159 pull_request: https://github.com/python/cpython/pull/16568 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue34344> _______________________________________
Change by miss-islington <mariatta.wijaya+miss-islington@gmail.com>: ---------- pull_requests: +16160 pull_request: https://github.com/python/cpython/pull/16569 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue34344> _______________________________________
miss-islington <mariatta.wijaya+miss-islington@gmail.com> added the comment: New changeset 8edde5caabc611c6320fd104244abe3a409cf0b6 by Miss Islington (bot) in branch '3.8': bpo-34344 Fix AbstractEventLoopPolicy.get_event_loop docstring (GH-16463) https://github.com/python/cpython/commit/8edde5caabc611c6320fd104244abe3a409... ---------- nosy: +miss-islington _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue34344> _______________________________________
miss-islington <mariatta.wijaya+miss-islington@gmail.com> added the comment: New changeset 4de3fbe27f672dcd9c24d3e99258f39b12c365a5 by Miss Islington (bot) in branch '3.7': bpo-34344 Fix AbstractEventLoopPolicy.get_event_loop docstring (GH-16463) https://github.com/python/cpython/commit/4de3fbe27f672dcd9c24d3e99258f39b12c... ---------- _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue34344> _______________________________________
Ned Deily <nad@python.org> added the comment: New changeset 88204a3908663a574919f9c17278bcabed0598fa by Ned Deily (Miss Islington (bot)) in branch '3.7': bpo-34344 Fix AbstractEventLoopPolicy.get_event_loop docstring (GH-16463) https://github.com/python/cpython/commit/88204a3908663a574919f9c17278bcabed0... ---------- nosy: +ned.deily _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue34344> _______________________________________
Ido Michael <michael.ido@gmail.com> added the comment: @yselivanov Can we close this? ---------- _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue34344> _______________________________________
Karthikeyan Singaravelan <tir.karthi@gmail.com> added the comment: Closing this as fixed. Thanks. ---------- resolution: -> fixed stage: patch review -> resolved status: open -> closed _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue34344> _______________________________________
participants (7)
-
Andrew Svetlov
-
Ido Michael
-
Karthikeyan Singaravelan
-
miss-islington
-
Ned Deily
-
Vlad Starostin
-
Yury Selivanov