New submission from Larry Hastings:
As discussed in #24824, inspect.Parameter currently only has a place to store
the value of a default argument. Which means, if a complicated bit of code was
used to produce that default argument, all we have left is the value, not the
code that arrived at that value. Which means all pydoc can do is display the
value.
When C extensions pass in their default arguments as expressions, it'd be great
if we could preserve that text and present it to the user. The example that
resulted in us creating this issue: _codecs.encode() and _codecs.decode() both
took an "encoding" parameter that defaulted to sys.getdefaultencoding(). The
value of that function was (always) "utf-8". It's slightly more meaningful to
display
encoding=sys.getdefaultencoding(),
than
encoding="utf-8",
in pydoc.
As a first approach, I propose we add a new member to inspect.Parameter, call
it "symbolic_default_value", which contains the expression passed in by
Argument Clinic (if present). pydoc should look for this member when computing
the documentation for a function, and prefer to present it to the user over the
actual default value.
----------
assignee: larry
messages: 248318
nosy: larry, serhiy.storchaka, yselivanov
priority: normal
severity: normal
stage: needs patch
status: open
title: pydoc should display the expression for a builtin argument default, not
its result
type: enhancement
versions: Python 3.6
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue24834>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com