Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert selectmodule.c to Argument Clinic #76119

Closed
taleinat opened this issue Nov 3, 2017 · 14 comments
Closed

Convert selectmodule.c to Argument Clinic #76119

taleinat opened this issue Nov 3, 2017 · 14 comments
Labels
3.8 only security fixes topic-argument-clinic type-feature A feature request or enhancement

Comments

@taleinat
Copy link
Contributor

taleinat commented Nov 3, 2017

BPO 31938
Nosy @vstinner, @taleinat, @larryhastings, @serhiy-storchaka, @asottile, @miss-islington
PRs
  • bpo-31938: Convert selectmodule.c to Argument Clinic #4265
  • bpo-34419: selectmodule.c does not compile on HP-UX due to bpo-31938 #8796
  • bpo-31938: Fix default-value signatures of several functions in the select module #21066
  • bpo-31938: Fix select.epoll.register() signature #21067
  • [3.9] bpo-31938: Fix default-value signatures of several functions in the select module (GH-21066) #21097
  • [3.8] bpo-31938: Fix default-value signatures of several functions in the select module (GH-21066) #21098
  • [3.8] bpo-31938: Fix default-value signatures of several functions in the select module (GH-21066) #21098
  • [3.8] bpo-31938: Fix default-value signatures of several functions in the select module (GH-21066) #21098
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2018-06-30.20:04:41.754>
    created_at = <Date 2017-11-03.21:20:30.369>
    labels = ['type-feature', '3.8', 'expert-argument-clinic']
    title = 'Convert selectmodule.c to Argument Clinic'
    updated_at = <Date 2020-06-23.22:28:18.280>
    user = 'https://github.com/taleinat'

    bugs.python.org fields:

    activity = <Date 2020-06-23.22:28:18.280>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2018-06-30.20:04:41.754>
    closer = 'taleinat'
    components = ['Argument Clinic']
    creation = <Date 2017-11-03.21:20:30.369>
    creator = 'taleinat'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 31938
    keywords = ['patch']
    message_count = 14.0
    messages = ['305514', '305520', '305526', '320439', '320805', '323651', '372138', '372206', '372208', '372210', '372211', '372212', '372214', '372215']
    nosy_count = 6.0
    nosy_names = ['vstinner', 'taleinat', 'larry', 'serhiy.storchaka', 'Anthony Sottile', 'miss-islington']
    pr_nums = ['4265', '8796', '21066', '21067', '21097', '21098', '21098', '21098']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue31938'
    versions = ['Python 3.8']

    @taleinat
    Copy link
    Contributor Author

    taleinat commented Nov 3, 2017

    Continuing the work begun as part of issue bpo-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.

    @taleinat taleinat added 3.7 (EOL) end of life topic-argument-clinic type-feature A feature request or enhancement labels Nov 3, 2017
    @taleinat
    Copy link
    Contributor Author

    taleinat commented Nov 3, 2017

    See PR 4265.

    @vstinner
    Copy link
    Member

    vstinner commented Nov 3, 2017

    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 bpo-31939.

    IHMO it's not a blocker issue. We can add it back later, once the issue bpo-31939 is implemented.

    @taleinat
    Copy link
    Contributor Author

    When ready, should this (and other AC conversions) be backported to the relevant 3.x branches?

    @taleinat
    Copy link
    Contributor Author

    New changeset 6dc57e2 by Tal Einat in branch 'master':
    bpo-31938: Convert selectmodule.c to Argument Clinic (GH-4265)
    6dc57e2

    @taleinat taleinat added 3.8 only security fixes and removed 3.7 (EOL) end of life labels Jun 30, 2018
    @taleinat
    Copy link
    Contributor Author

    New changeset 0e6e7a1 by Tal Einat (Michael Osipov) in branch 'master':
    bpo-34419: selectmodule.c does not compile on HP-UX due to bpo-31938 (GH-8796)
    0e6e7a1

    @asottile
    Copy link
    Mannequin

    asottile mannequin commented Jun 23, 2020

    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

    @serhiy-storchaka
    Copy link
    Member

    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.

    @vstinner
    Copy link
    Member

    New changeset d051801 by Anthony Sottile in branch 'master':
    bpo-31938: Fix default-value signatures of several functions in the select module (GH-21066)
    d051801

    @miss-islington
    Copy link
    Contributor

    New changeset 60cbdc8 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)
    60cbdc8

    @miss-islington
    Copy link
    Contributor

    New changeset 48fc35a 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)
    48fc35a

    @vstinner
    Copy link
    Member

    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.

    @vstinner
    Copy link
    Member

    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".

    @vstinner
    Copy link
    Member

    Thanks Anthony Sottile for fixing pydoc select! The fix is now in 3.8, 3.9 and master branches.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.8 only security fixes topic-argument-clinic type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants