Repository navigation
inspect.signature() doesn't parse __text_signature__ containing a newline character #85267
Description
Activity
$ ./python Python 3.10.0a0 (heads/unicode_latin1:40855c7064, Jun 24 2020, 00:20:07) >>> import select >>> select.epoll.register.__text_signature__ '($self, /, fd,\n eventmask=select.EPOLLIN | select.EPOLLPRI | select.EPOLLOUT)' >>> import inspect >>> inspect.signature(select.epoll.register) <Signature (self, /, fd)>
=> eventmask parameter is gone!
Either signature() must raise an exception, or it must handle a __text_signature__ containing a newline character.
Issue spotted on bpo-31938 when fixing "./python -m pydoc select".
By the way, as expected, pydoc shows:
Help on method_descriptor in select.epoll:
---$ ./python -m pydoc select.epoll.register
select.epoll.register = register(self, /, fd) Registers a new fd or raises an OSError if the fd is already registered. (...)
- added3.10 (EOL)end of lifeend of lifestdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
on Jun 23, 2020 Looking into this, it appears to be due to the default value and not due to the newline
I've stumbled upon two simplifications to the routines in inspect but not a fix for this
- bpo-20684: Remove unused inspect._signature_get_bound_param #21100
- gh-99815: remove unused 'invalid' sentinel value and code that checks for it in inspect.signature parsing #21104
the following code is hit because
ast.literal_eval(...)fails for the|d expression:Lines 2069 to 2070 in 2f9ada9
if o is invalid: return None this causes the parameter to be skipped entirely
Sadly, I don't have the bandwidth to work on this issue, so I just close it.
Reopening as there's an active PR fixing this.
What is the active PR?
- added a commit that references this issue
on Dec 21, 2022 - added a commit that references this issue
on Dec 28, 2022
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: