python / cpython

The Python programming language
https://www.python.org/
Other
61.16k stars 29.52k forks source link

__text_signature__ parser silently drops arguments with certain unsupported default forms #87142

Open 379dc349-3a10-424f-b9d2-a0104f092359 opened 3 years ago

379dc349-3a10-424f-b9d2-a0104f092359 commented 3 years ago
BPO 42976
Nosy @anntzer

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: ```python assignee = None closed_at = None created_at = labels = ['extension-modules'] title = '__text_signature__ parser silently drops arguments with certain unsupported default forms' updated_at = user = 'https://github.com/anntzer' ``` bugs.python.org fields: ```python activity = actor = 'Antony.Lee' assignee = 'none' closed = False closed_date = None closer = None components = ['Extension Modules'] creation = creator = 'Antony.Lee' dependencies = [] files = [] hgrepos = [] issue_num = 42976 keywords = [] message_count = 1.0 messages = ['385335'] nosy_count = 1.0 nosy_names = ['Antony.Lee'] pr_nums = [] priority = 'normal' resolution = None stage = None status = 'open' superseder = None type = None url = 'https://bugs.python.org/issue42976' versions = [] ```

379dc349-3a10-424f-b9d2-a0104f092359 commented 3 years ago

Starting from the keyword-arguments example at https://docs.python.org/3/extending/extending.html#keyword-parameters-for-extension-functions, change the docstring of parrot to "parrot(voltage, state, action, type=1<<5)\n--\n\n" (yes, the documented default value for type does not correspond to the actual implementation, but that's irrelevant here). Compiling the extension module and running pydoc on it yields the following parsed signature for parrot: parrot(voltage, state, action) i.e. the type parameter got silently dropped. (Note that 1<<5 can legitimately occur, e.g. as a bitmask flag, especially given that one currently cannot refer to globals in __text_signature__ (https://bugs.python.org/issue37881).)