This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author larry
Recipients larry, meador.inge, nadeem.vawda, serhiy.storchaka
Date 2014-01-09.00:52:45
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
I just realized, you're misunderstanding what the first line of the docstring is.

When you run help(function_written_in_Python), the first line of the help is the function's signature rendered in text.  That's generated by "pydoc", which gets signature information from inspect.  Now, it used to be that this didn't work for builtins.  pydoc would look at the function, say "I can't get metadata for this function, I'll skip it".  And it'd just print the builtin's docstring.  Builtins worked around this problem by having their first line *look* like a Python signature.  So the user kind of couldn't tell the difference.

As part of adding Argument Clinic, I changed this.  Now the first line of a docstring is a machine-readable representation of the signature of the function.  Internally it gets split off from the docstring--you won't see it if you look at builtin.__doc__.  Instead this first line is provided via a new property called __text_signature__.  inspect.Signature supports builtins by parsing this string.

As it happens, the format of the string happens to look exactly like a Python function definition.  Because... it is!  inspect.Signature parses the string by passing it in to ast.parse.

"decompressobj([wbits], [zdict])" is not legal Python; if you gave that to ast.parse it would reject it.  (I tried, with PEP 457, but so far nobody has been interested.)  On the other hand, ast.parse is totally happy with "decompressobj(wbits=None, zdict=None)".
Date User Action Args
2014-01-09 00:52:46larrysetrecipients: + larry, nadeem.vawda, meador.inge, serhiy.storchaka
2014-01-09 00:52:46larrysetmessageid: <>
2014-01-09 00:52:46larrylinkissue20193 messages
2014-01-09 00:52:45larrycreate