classification
Title: Convert selectmodule.c to Argument Clinic
Type: enhancement Stage: resolved
Components: Argument Clinic Versions: Python 3.8
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Anthony Sottile, larry, miss-islington, serhiy.storchaka, taleinat, vstinner
Priority: normal Keywords: patch

Created on 2017-11-03 21:20 by taleinat, last changed 2020-06-23 22:28 by vstinner. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 4265 merged taleinat, 2017-11-03 21:58
PR 8796 merged michael-o, 2018-08-17 10:48
PR 21066 merged Anthony Sottile, 2020-06-23 03:10
PR 21067 closed vstinner, 2020-06-23 09:46
PR 21097 merged Anthony Sottile, 2020-06-23 21:59
PR 21098 merged Anthony Sottile, 2020-06-23 22:00
PR 21098 merged Anthony Sottile, 2020-06-23 22:00
PR 21098 merged Anthony Sottile, 2020-06-23 22:00
Messages (14)
msg305514 - (view) Author: Tal Einat (taleinat) * (Python committer) Date: 2017-11-03 21:20
Continuing the work begun as part of issue #20182, this is regarding the Argument Clinic conversion of Modules/selectmodule.c.h.

I have a complete conversion ready and will create a PR momentarily.
msg305520 - (view) Author: Tal Einat (taleinat) * (Python committer) Date: 2017-11-03 22:00
See PR 4265.
msg305526 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-11-03 23:33
While reviewing PR 4265, I noticed that the return type like "-> None" or "-> int" is removed from the function definition, so the PR removes this information. But it seems to be a limitation of Argument Clinic: I opened the issue #31939.

IHMO it's not a blocker issue. We can add it back later, once the issue #31939 is implemented.
msg320439 - (view) Author: Tal Einat (taleinat) * (Python committer) Date: 2018-06-25 20:26
When ready, should this (and other AC conversions) be backported to the relevant 3.x branches?
msg320805 - (view) Author: Tal Einat (taleinat) * (Python committer) Date: 2018-06-30 20:02
New changeset 6dc57e2a20c5beb99e8bf5eb04cc836d53fa9aee by Tal Einat in branch 'master':
bpo-31938: Convert selectmodule.c to Argument Clinic (GH-4265)
https://github.com/python/cpython/commit/6dc57e2a20c5beb99e8bf5eb04cc836d53fa9aee
msg323651 - (view) Author: Tal Einat (taleinat) * (Python committer) Date: 2018-08-17 11:43
New changeset 0e6e7a1e52a53090e33ebef13f8f1fbe9bec2375 by Tal Einat (Michael Osipov) in branch 'master':
bpo-34419: selectmodule.c does not compile on HP-UX due to bpo-31938 (GH-8796)
https://github.com/python/cpython/commit/0e6e7a1e52a53090e33ebef13f8f1fbe9bec2375
msg372138 - (view) Author: Anthony Sottile (Anthony Sottile) * Date: 2020-06-23 03:11
This appears to have broken pydoc of the select module, I've attached a patch

$ python3.8 -m pydoc select
Traceback (most recent call last):
  File "/usr/lib/python3.8/inspect.py", line 2004, in wrap_value
    value = eval(s, module_dict)
  File "<string>", line 1, in <module>
NameError: name 'EPOLLIN' is not defined

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.8/inspect.py", line 2007, in wrap_value
    value = eval(s, sys_module_dict)
  File "<string>", line 1, in <module>
NameError: name 'EPOLLIN' is not defined

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.8/runpy.py", line 193, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.8/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/usr/lib/python3.8/pydoc.py", line 2769, in <module>
    cli()
  File "/usr/lib/python3.8/pydoc.py", line 2731, in cli
    help.help(arg)
  File "/usr/lib/python3.8/pydoc.py", line 1971, in help
    elif request: doc(request, 'Help on %s:', output=self._output)
  File "/usr/lib/python3.8/pydoc.py", line 1694, in doc
    pager(render_doc(thing, title, forceload))
  File "/usr/lib/python3.8/pydoc.py", line 1687, in render_doc
    return title % desc + '\n\n' + renderer.document(object, name)
  File "/usr/lib/python3.8/pydoc.py", line 384, in document
    if inspect.ismodule(object): return self.docmodule(*args)
  File "/usr/lib/python3.8/pydoc.py", line 1183, in docmodule
    contents.append(self.document(value, key, name))
  File "/usr/lib/python3.8/pydoc.py", line 385, in document
    if inspect.isclass(object): return self.docclass(*args)
  File "/usr/lib/python3.8/pydoc.py", line 1352, in docclass
    attrs = spill("Methods %s:\n" % tag, attrs,
  File "/usr/lib/python3.8/pydoc.py", line 1298, in spill
    push(self.document(value,
  File "/usr/lib/python3.8/pydoc.py", line 386, in document
    if inspect.isroutine(object): return self.docroutine(*args)
  File "/usr/lib/python3.8/pydoc.py", line 1411, in docroutine
    signature = inspect.signature(object)
  File "/usr/lib/python3.8/inspect.py", line 3093, in signature
    return Signature.from_callable(obj, follow_wrapped=follow_wrapped)
  File "/usr/lib/python3.8/inspect.py", line 2842, in from_callable
    return _signature_from_callable(obj, sigcls=cls,
  File "/usr/lib/python3.8/inspect.py", line 2296, in _signature_from_callable
    return _signature_from_builtin(sigcls, obj,
  File "/usr/lib/python3.8/inspect.py", line 2109, in _signature_from_builtin
    return _signature_fromstr(cls, func, s, skip_bound_arg)
  File "/usr/lib/python3.8/inspect.py", line 2057, in _signature_fromstr
    p(name, default)
  File "/usr/lib/python3.8/inspect.py", line 2039, in p
    default_node = RewriteSymbolics().visit(default_node)
  File "/usr/lib/python3.8/ast.py", line 360, in visit
    return visitor(node)
  File "/usr/lib/python3.8/ast.py", line 445, in generic_visit
    new_node = self.visit(old_value)
  File "/usr/lib/python3.8/ast.py", line 360, in visit
    return visitor(node)
  File "/usr/lib/python3.8/ast.py", line 445, in generic_visit
    new_node = self.visit(old_value)
  File "/usr/lib/python3.8/ast.py", line 360, in visit
    return visitor(node)
  File "/usr/lib/python3.8/inspect.py", line 2031, in visit_Name
    return wrap_value(node.id)
  File "/usr/lib/python3.8/inspect.py", line 2009, in wrap_value
    raise RuntimeError()
RuntimeError
msg372206 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2020-06-23 20:47
There is no need to change default-value signatures. The root problem is that select.epoll.register does not have the __module__ attribute.

Well, seems that all method objects do not have the __module__ attribute. There are two solutions:

1. Make inspect falling back to __objclass__.__module__.
2. Set __module__ for method objects.

But this is a separate issue.
msg372208 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-06-23 21:50
New changeset d051801052211b533c46a593b1c1bccf649a171c by Anthony Sottile in branch 'master':
bpo-31938: Fix default-value signatures of several functions in the select module (GH-21066)
https://github.com/python/cpython/commit/d051801052211b533c46a593b1c1bccf649a171c
msg372210 - (view) Author: miss-islington (miss-islington) Date: 2020-06-23 22:17
New changeset 60cbdc81d1bd5c175ff890ee4cfdc85c10090b75 by Anthony Sottile in branch '3.8':
[3.8] bpo-31938: Fix default-value signatures of several functions in the select module (GH-21066) (GH-21098)
https://github.com/python/cpython/commit/60cbdc81d1bd5c175ff890ee4cfdc85c10090b75
msg372211 - (view) Author: miss-islington (miss-islington) Date: 2020-06-23 22:19
New changeset 48fc35ada7c4237f11bb9638387bfe5b4cebfb12 by Anthony Sottile in branch '3.9':
[3.9] bpo-31938: Fix default-value signatures of several functions in the select module (GH-21066) (GH-21097)
https://github.com/python/cpython/commit/48fc35ada7c4237f11bb9638387bfe5b4cebfb12
msg372212 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-06-23 22:23
> There is no need to change default-value signatures. The root problem is that select.epoll.register does not have the __module__ attribute.

Oh, I saw your comment after merging Anthony's PR. At least, I confirm that it fix the reported issue: "./python -m pydoc select" doesn't fail anymore.

Maybe open a separated issue for the __module__ attribute issue.
msg372214 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-06-23 22:27
pydoc doesn't show the eventmask parameter whereas it is in select.epoll.register.__text_signature__. I created bpo-41095: "inspect.signature() doesn't parse __text_signature__ containing a newline character".
msg372215 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-06-23 22:28
Thanks Anthony Sottile for fixing pydoc select! The fix is now in 3.8, 3.9 and master branches.
History
Date User Action Args
2020-06-23 22:28:18vstinnersetmessages: + msg372215
2020-06-23 22:27:18vstinnersetmessages: + msg372214
2020-06-23 22:23:19vstinnersetmessages: + msg372212
2020-06-23 22:19:49miss-islingtonsetmessages: + msg372211
2020-06-23 22:17:06miss-islingtonsetnosy: + miss-islington
messages: + msg372210
2020-06-23 22:00:44Anthony Sottilesetpull_requests: + pull_request20267
2020-06-23 22:00:44Anthony Sottilesetpull_requests: + pull_request20266
2020-06-23 22:00:36Anthony Sottilesetpull_requests: + pull_request20265
2020-06-23 21:59:19Anthony Sottilesetpull_requests: + pull_request20264
2020-06-23 21:50:04vstinnersetmessages: + msg372208
2020-06-23 20:47:36serhiy.storchakasetmessages: + msg372206
2020-06-23 09:46:18vstinnersetpull_requests: + pull_request20236
2020-06-23 03:11:11Anthony Sottilesetmessages: + msg372138
2020-06-23 03:10:20Anthony Sottilesetnosy: + Anthony Sottile

pull_requests: + pull_request20235
2018-08-17 11:43:07taleinatsetmessages: + msg323651
2018-08-17 10:48:58michael-osetpull_requests: + pull_request8272
2018-06-30 20:04:54taleinatsetversions: + Python 3.8, - Python 3.7
2018-06-30 20:04:41taleinatsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2018-06-30 20:04:07taleinatsetpull_requests: - pull_request7637
2018-06-30 20:04:05taleinatsetpull_requests: - pull_request7636
2018-06-30 20:04:03taleinatsetmessages: - msg320779
2018-06-30 20:04:01taleinatsetmessages: - msg320777
2018-06-30 20:02:52taleinatsetmessages: + msg320805
2018-06-30 13:15:56taleinatsetmessages: + msg320779
2018-06-30 13:03:21taleinatsetmessages: + msg320777
2018-06-30 13:03:20miss-islingtonsetpull_requests: + pull_request7637
2018-06-30 12:56:47taleinatsetpull_requests: + pull_request7636
2018-06-30 12:45:56taleinatsetmessages: - msg320775
2018-06-30 12:44:57taleinatsetpull_requests: - pull_request7634
2018-06-30 12:44:47taleinatsetpull_requests: - pull_request7450
2018-06-30 12:44:41miss-islingtonsetpull_requests: + pull_request7634
2018-06-30 12:43:25taleinatsetmessages: + msg320775
2018-06-25 20:26:56taleinatsetmessages: + msg320439
2018-06-21 06:45:26taleinatsetpull_requests: + pull_request7450
2017-11-03 23:33:09vstinnersetmessages: + msg305526
2017-11-03 22:00:23taleinatsetmessages: + msg305520
2017-11-03 21:58:15taleinatsetkeywords: + patch
stage: patch review
pull_requests: + pull_request4228
2017-11-03 21:20:30taleinatcreate