-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
Comments
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. |
See PR 4265. |
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. |
When ready, should this (and other AC conversions) be backported to the relevant 3.x branches? |
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 |
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:
But this is a separate issue. |
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. |
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". |
Thanks Anthony Sottile for fixing pydoc select! The fix is now in 3.8, 3.9 and master branches. |
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:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: