New submission from Dan Snider <[email protected]>:
The interpreter matches the values in func.__defaults__ with the calculated
positional argument names "right-to-left", while inspect does does so
"left-to-right". In every day usage, for "normal" functions, generated by the
compiler from "normal", hand-typed source code, it is impossible to encounter
this.
>>> def f(x): return x
>>> x.__defaults__ = (1,2,3)
>>> inspect.getfullargspec(f)
FullArgSpec(args=['x'], varargs=None, varkw=None, defaults=(1,), kwonlyargs=[],
kwonlydefaults=None, annotations={})
>>> f()
3
>>> f.__defaults__
(1, 2, 3)
So I'll be honest: I've submitted this particularly inconsequential bug report
as a pretext to ask for advice on how to contribute here, because frankly, this
is getting out of hand. While I haven't counted, it would not surprise me if I
have more than 20 open tickets on here currently. While that may not be
uncommon it does bother me slightly. And those are just the ones I had the time
and/or remembered to to submit a ticket for. There's another 45-50 whose
location I'm certain of, fully documented and fixed.
If this little digression is against some sort of rules, then I apologize now
and must concur. That being said, despite my lack of a formal education, my
seemingly never-ending quest to push the interpreter to its limits, hunting for
the most esoteric of optimizations (and flaws) has turned out to be quite the
hobby. I've aquired a great deal of knowledge on the subject which, in the
grand scheme of things is being wasted, as the only thing of actual
significance I could see myself doing with it is using it to contribute here.
But when I consider the amount of time I've wasted on the matter already on
this, I've totally lost faith in my own ability to judge what might constitute
a good resource on the subject of GH. The other venues I'm aware of haven't
been helpful to me so I don't even bother with them anymore. I will read the
dev guide again, since it has been a while. However to my recollection the
problems I had with it wasn't technicality per se, it was that it was it was
full of totally foreign terminology to me, with words and phrases such as
"pulling on this while the squisher of that squasher pushes on that".
----------
components: Library (Lib)
messages: 343613
nosy: bup
priority: normal
severity: normal
status: open
title: Incorrect application of func.__defaults__ by inspect's signature APIs
type: behavior
versions: Python 3.7, Python 3.8
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue37063>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com