msg209658 - (view) |
Author: Yury Selivanov (yselivanov) * |
Date: 2014-01-29 17:00 |
Should we finally deprecate getfullargspec? With the AC and positional-only parameters support, getfullargspec doesn't provide full information anymore.
By deprecation I mean changing its existing note "Consider using the new Signature Object interface, which provides a better way of introspecting functions." to "Deprecated since version 3.4: Use inspect.signature() instead".
|
msg209664 - (view) |
Author: Brett Cannon (brett.cannon) * |
Date: 2014-01-29 18:28 |
I vote deprecation with no stated plans of removal
|
msg209665 - (view) |
Author: Brett Cannon (brett.cannon) * |
Date: 2014-01-29 18:28 |
Although I say do it in 3.5.
|
msg209692 - (view) |
Author: Nick Coghlan (ncoghlan) * |
Date: 2014-01-29 23:17 |
As Brett said - let's do a documented deprecation in 3.5.
|
msg216317 - (view) |
Author: Stéphane Wirtel (matrixise) * |
Date: 2014-04-15 15:47 |
In this patch, I deprecate the inspect.getfullargspec function in the documentation and raise an warnings.warn with DeprecationWarning.
Need feedback, because the inspect.getargspec() informs the user that it can use the getfullargspec() and I think we should use inspect.signature instead of inspect.getfullargspec() and inspect.getargspec().
Thank you
|
msg216318 - (view) |
Author: Stéphane Wirtel (matrixise) * |
Date: 2014-04-15 15:47 |
Here is the output of my test:
> ./python3.5 -Wd test.py
test.py:9: DeprecationWarning: Deprecated
warnings.warn('Deprecated', DeprecationWarning)
/private/tmp/python/lib/python3.5/inspect.py:955: DeprecationWarning: Use inspect.signature() instead of inspect.getfullargspec()
warnings.warn("Use inspect.signature() instead of inspect.getfullargspec()", DeprecationWarning)
FullArgSpec(args=[], varargs='args', varkw='kwargs', defaults=None, kwonlyargs=[], kwonlydefaults=None, annotations={})
|
msg216327 - (view) |
Author: Brett Cannon (brett.cannon) * |
Date: 2014-04-15 16:16 |
I was thinking about suggesting we don't code deprecate getfullargspec() but the function seems to be new to Python 3 and so that worry for Python 2/3 code is not founded.
|
msg216328 - (view) |
Author: Yury Selivanov (yselivanov) * |
Date: 2014-04-15 16:20 |
How about we deprecate with a warning getfullargspec(); deprecate getargspec() in docs only (in 3.6 we'll fully deprecate all function parameters API except Signature)?
|
msg216333 - (view) |
Author: Stéphane Wirtel (matrixise) * |
Date: 2014-04-15 16:40 |
Just one thing, how do you work for the deprecation?
1. you deprecate in the doc for 3.5?
2. you deprecate in the code for 3.6?
3. you remove the code in 3.7?
What's the strategy in this case or in general?
Thanks
|
msg216337 - (view) |
Author: Brett Cannon (brett.cannon) * |
Date: 2014-04-15 16:58 |
How warnings are handled vary from case to case. Typically its documentation-only if we want to warn people that they shouldn't use something because there is a better alternative but the code is not fundamentally broken and its in Python 2. If there is something wrong with it or it's just in Python 3 then a deprecation warning with a decided amount of time for when the code will be removed.
|
msg216339 - (view) |
Author: Stéphane Wirtel (matrixise) * |
Date: 2014-04-15 17:02 |
ok, so in this case, I can only change the documentation with a ".. deprecated:". But for the future, how can we know we have to deprecate this function for >= 3.6 ? Will you parse the documentation and check there is an deprecation to add in the code?
Or is there a file with the "future" deprecations?
Are you agree with the deprecation in the documentation?
|
msg216340 - (view) |
Author: Yury Selivanov (yselivanov) * |
Date: 2014-04-15 17:07 |
I'd +1 for:
1. Deprecating getfullargsspec in docs;
2. Deprecating getargspec in docs and code (since it's an ancient and outdated API)
Brett?
|
msg216341 - (view) |
Author: Stéphane Wirtel (matrixise) * |
Date: 2014-04-15 17:09 |
Brett,
If you agree with Yury, I will provide a patch with these tasks.
|
msg216342 - (view) |
Author: Brett Cannon (brett.cannon) * |
Date: 2014-04-15 17:28 |
Since getfullargspec is new in Python 3 and inspect.signature fundamentally improves things in Python 3 due to Argument Clinic I would say go ahead and code deprecate getfullargspec (we can do a DeprecationWarning for 3.5 and 3.6 and remove in 3.7; people needing compatibility can just use getargspec). As for getargspec, it was already deprecated so just leave it deprecated and update its message to say to use inspect.signature.
As for keeping track of this stuff, Stéphane, as part of the test that makes sure the warning is raised, add to that test -- don't need a separate method -- some code that will fail if the function exists in Python 3.7 or later.
|
msg216365 - (view) |
Author: Stéphane Wirtel (matrixise) * |
Date: 2014-04-15 19:28 |
Need your feedback for this patch
Thank you
|
msg216385 - (view) |
Author: Nick Coghlan (ncoghlan) * |
Date: 2014-04-15 21:04 |
Note that getargspec() depends on getfullargspec() so deprecating the latter *will* cause issues for single-source code (unless they switch to using the funcsigs backport).
|
msg216387 - (view) |
Author: Yury Selivanov (yselivanov) * |
Date: 2014-04-15 21:20 |
Nick, good catch. OK, let's just deprecate it in the docs for 3.5, so people (hopefully) will not write new code with it.
|
msg216621 - (view) |
Author: Larry Hastings (larry) * |
Date: 2014-04-16 23:17 |
+1 to doc deprecation and adding a DeprecationWarning for 3.5.
|
msg217581 - (view) |
Author: Stéphane Wirtel (matrixise) * |
Date: 2014-04-30 08:09 |
@Larry Hasting: If you check my patch, it's the case where I modify the
documentation and add a DeprecationWarning in the code.
@Yury Selivanov, @Nick Coghlan, @Brett Cannon: From your point of views,
I need to propose a patch just for the documentation, I agree with that.
@Brett Cannon: In the current patch, I implemented a test with the
python version. If the version is greater or equal than 3.7, in this
case, I raise an exception.
I propose to follow the solution of @Yury Selinanov, just deprecate the
function in the documentation and keep the check in the unit test for
the version.
Are you agree?
Thanks
|
msg243777 - (view) |
Author: Yury Selivanov (yselivanov) * |
Date: 2015-05-21 18:57 |
Please see the new patch.
So it's time to deprecate getargspec with a warning (was softly deprecated in 3.0).
getfullargspec() and getcallargs() deprecation is documented.
I also want to deprecate formatargspec() and formatargvalues(), but Signature does not provide equivalents. Should we add them?
|
msg243835 - (view) |
Author: Roundup Robot (python-dev) |
Date: 2015-05-22 15:39 |
New changeset 3a5fec5e025d by Yury Selivanov in branch 'default':
Issue 20438: Deprecate inspect.getargspec() and friends.
https://hg.python.org/cpython/rev/3a5fec5e025d
|
msg243848 - (view) |
Author: Berker Peksag (berker.peksag) * |
Date: 2015-05-22 19:42 |
Just a minor comment on the patch:
+ warnings.warn("inspect.getargspec() is deprecated, "
+ "use inspect.signature() instead", DeprecationWarning)
Can you also add "stacklevel=2"?
|
msg243850 - (view) |
Author: Roundup Robot (python-dev) |
Date: 2015-05-22 20:09 |
New changeset 666e5b554f32 by Yury Selivanov in branch 'default':
Issue 20438: Adjust stacklevel of inspect.getargspec() warning.
https://hg.python.org/cpython/rev/666e5b554f32
|
msg243851 - (view) |
Author: Roundup Robot (python-dev) |
Date: 2015-05-22 20:28 |
New changeset 621e98bfc74b by Yury Selivanov in branch 'default':
Issue 20438: Add a note about deprecating old inspect APIs to whatsnew.
https://hg.python.org/cpython/rev/621e98bfc74b
|
msg243852 - (view) |
Author: Yury Selivanov (yselivanov) * |
Date: 2015-05-22 20:28 |
Thanks Berker!
|
msg243853 - (view) |
Author: Yury Selivanov (yselivanov) * |
Date: 2015-05-22 20:30 |
I'm copying/pasting my latest commit message on this issue here:
"""Add a note about deprecating old inspect APIs to whatsnew.
Also, deprecate formatargspec, formatargvalues, and getargvalues
functions. Since we are deprecating 'getfullargspec' function in
3.5 (documentation only, no DeprecationWarning), it makes sense
to also deprecate functions designed to be directly used with it.
In 3.6 we will remove 'getargsspec' function (was deprecated since
Python 3.0), and start raising DeprecationWarnings in other
'getarg*' family of functions. We can remove them in 3.7 or later.
Also, it is worth noting, that Signature API does not provide 100%
of functionality that deprecated APIs have. It is important to do
a soft deprecation of outdated APIs in 3.5 to gather users feedback,
and improve Signature object."""
|
msg250805 - (view) |
Author: Markus Unterwaditzer (untitaker) |
Date: 2015-09-15 20:42 |
It should be properly noted that the API isn't going to be actually removed anytime soon.
Also I think issuing a warning about this was a mistake. For software that wants to stay compatible with both Python 2 and 3 it's basically useless.
|
msg250808 - (view) |
Author: Markus Unterwaditzer (untitaker) |
Date: 2015-09-15 20:46 |
My last comment was in reference to getfullargspec, which is, as far as I understand, not going to be deprecated until after 3.7.
|
msg253434 - (view) |
Author: Ned Batchelder (nedbat) * |
Date: 2015-10-25 19:44 |
I'm confused: the discussion here is mostly about updating docs to note deprecation. Then at the very end, is an off-hand remark about removing getargspec.
The docs for getargspec currently read, "This function will be removed in Python 3.6." Why? We keep all sorts of old APIs for the sake of backward compatibility, why is this one different?
|
msg253436 - (view) |
Author: Yury Selivanov (yselivanov) * |
Date: 2015-10-25 21:13 |
> The docs for getargspec currently read, "This function will be removed in Python 3.6." Why? We keep all sorts of old APIs for the sake of backward compatibility, why is this one different?
getargspec was deprecated since 3.0. Besides that, it returns incomplete information about function parameters: keyword-only parameters won't be introspected at all for instance.
Migration path is very simple and clear -- just use getfullargspec (almost 100% backwards compatible), which won't be removed probably till Python 4.
|
msg253473 - (view) |
Author: R. David Murray (r.david.murray) * |
Date: 2015-10-26 13:38 |
The thing is, we've adopted a policy that if something exists in python2.7 we shouldn't delete it in python3 until after 2.7 is officially out of maintenance (at the earliest), in order to facilitate single-source porting to python3. That policy was adopted relatively recently, after the deprecation warning mentioning 3.6 was added in this issue, as I recall it.
|
msg253475 - (view) |
Author: Ned Batchelder (nedbat) * |
Date: 2015-10-26 14:39 |
This is the situation I am in: coverage.py uses getargspec in a very simple way in its tooling. I support 2.7 and 3.5, so I have to do this:
try:
getargspec = inspect.getfullargspec
except AttributeError:
getargspec = inspect.getargspec
argspec = getargspec(function)
It seems like needless churn.
|
msg253500 - (view) |
Author: Yury Selivanov (yselivanov) * |
Date: 2015-10-26 20:34 |
> The thing is, we've adopted a policy that if something exists in python2.7 we shouldn't delete it in python3 until after 2.7 is officially out of maintenance (at the earliest), in order to facilitate single-source porting to python3. That policy was adopted relatively recently, after the deprecation warning mentioning 3.6 was added in this issue, as I recall it.
In this case we better resurrect getargspec(). Here's an issue for that: #25486
|
msg253501 - (view) |
Author: Yury Selivanov (yselivanov) * |
Date: 2015-10-26 20:37 |
> This is the situation I am in: coverage.py uses getargspec in a very simple way in its tooling. I support 2.7 and 3.5, so I have to do this:
try:
getargspec = inspect.getfullargspec
except AttributeError:
getargspec = inspect.getargspec
argspec = getargspec(function)
I think it was me who submitted this code to coverage.py.. :) It might be worthwhile to keep it anyways, as getfullargspec uses the signature API, which supports a wider range of callables.
|
msg254892 - (view) |
Author: Vedran Čačić (veky) * |
Date: 2015-11-19 09:49 |
> Also, it is worth noting, that Signature API does not provide 100%
of functionality that deprecated APIs have. It is important to do
a soft deprecation of outdated APIs in 3.5 to gather users feedback,
and improve Signature object.
Well, here is a feedback about lost functionality. inspect.getcallargs had a very nice property that it automatically bound the first argument to the instance of bound methods. It seems I have no general way to do it with Signature.bind. Of course I can put
arguments['self'] = method.__self__
afterwards, but theoretically, the argument doesn't have to be called 'self'. And anyway, I would like something that works seamlessly with bound methods and ordinary functions.
|
msg254899 - (view) |
Author: R. David Murray (r.david.murray) * |
Date: 2015-11-19 14:46 |
Please open a new issue for that observation/request.
|
msg282173 - (view) |
Author: Nick Coghlan (ncoghlan) * |
Date: 2016-12-01 13:20 |
Noting for the record, as the general way of querying an unbound method for the name of the first parameter and adding it to the bound arguments:
def add_instance_arg(callable, bound_args):
try:
self = callable.__self__
func = callable.__func__
except AttributeError:
return # Not a bound method
unbound_sig = inspect.signature(func)
for name in unbound_sig.parameters:
bound_args.arguments[name] = self
break
>>> method = C().method
>>> sig = inspect.signature(method)
>>> sig
<Signature (arg)>
>>> args = sig.bind(1)
>>> args
<BoundArguments (arg=1)>
>>> add_instance_arg(method, args)
>>> args
<BoundArguments (arg=1, self=<__main__.C object at 0x7f07ab719668>)>
|
msg288334 - (view) |
Author: Berker Peksag (berker.peksag) * |
Date: 2017-02-22 05:45 |
New changeset 0899b9809547ec2894dcf88cf4bba732c5d47d0d by Berker Peksag in branch 'master':
bpo-28814: Undeprecate inadvertently deprecated inspect functions. (#122)
https://github.com/python/cpython/commit/0899b9809547ec2894dcf88cf4bba732c5d47d0d
|
msg290422 - (view) |
Author: Nick Coghlan (ncoghlan) * |
Date: 2017-03-24 23:50 |
New changeset 0246422b974b1a0c50dd30b0e1a1138674ef87a5 by Nick Coghlan (Berker Peksag) in branch '3.5':
bpo-28814: Undeprecate inadvertently deprecated inspect functions. (#122) (#244)
https://github.com/python/cpython/commit/0246422b974b1a0c50dd30b0e1a1138674ef87a5
|
msg290425 - (view) |
Author: Nick Coghlan (ncoghlan) * |
Date: 2017-03-24 23:50 |
New changeset 2197eac6104311472f200645bc844adb46444b10 by Nick Coghlan (Berker Peksag) in branch '3.6':
bpo-28814: Undeprecate inadvertently deprecated inspect functions. (#122) (#243)
https://github.com/python/cpython/commit/2197eac6104311472f200645bc844adb46444b10
|
|
Date |
User |
Action |
Args |
2022-04-11 14:57:57 | admin | set | github: 64637 |
2021-09-29 12:48:03 | hugovk | set | nosy:
+ hugovk
pull_requests:
+ pull_request26990 |
2017-03-24 23:50:35 | ncoghlan | set | messages:
+ msg290425 |
2017-03-24 23:50:19 | ncoghlan | set | messages:
+ msg290422 |
2017-02-22 22:10:11 | berker.peksag | set | pull_requests:
+ pull_request209 |
2017-02-22 22:08:02 | berker.peksag | set | pull_requests:
+ pull_request207 |
2017-02-22 05:45:53 | berker.peksag | set | messages:
+ msg288334 |
2017-02-15 16:54:27 | mbussonn | set | pull_requests:
+ pull_request84 |
2016-12-01 13:20:28 | ncoghlan | set | messages:
+ msg282173 |
2015-11-19 14:46:37 | r.david.murray | set | messages:
+ msg254899 |
2015-11-19 09:49:18 | veky | set | nosy:
+ veky messages:
+ msg254892
|
2015-10-26 20:37:11 | yselivanov | set | messages:
+ msg253501 |
2015-10-26 20:34:21 | yselivanov | set | dependencies:
+ Resurrect inspect.getargspec() in 3.6 messages:
+ msg253500 |
2015-10-26 14:39:07 | nedbat | set | messages:
+ msg253475 |
2015-10-26 13:38:53 | r.david.murray | set | nosy:
+ r.david.murray messages:
+ msg253473
|
2015-10-25 21:13:47 | yselivanov | set | messages:
+ msg253436 |
2015-10-25 19:44:15 | nedbat | set | nosy:
+ nedbat messages:
+ msg253434
|
2015-09-15 20:46:52 | untitaker | set | messages:
+ msg250808 |
2015-09-15 20:42:14 | untitaker | set | nosy:
+ untitaker messages:
+ msg250805
|
2015-05-22 20:30:40 | yselivanov | set | messages:
+ msg243853 |
2015-05-22 20:28:39 | yselivanov | set | messages:
+ msg243852 |
2015-05-22 20:28:16 | python-dev | set | messages:
+ msg243851 |
2015-05-22 20:09:59 | python-dev | set | messages:
+ msg243850 |
2015-05-22 19:42:13 | berker.peksag | set | nosy:
+ berker.peksag messages:
+ msg243848
|
2015-05-22 15:39:20 | yselivanov | set | status: open -> closed resolution: fixed stage: resolved |
2015-05-22 15:39:03 | python-dev | set | nosy:
+ python-dev messages:
+ msg243835
|
2015-05-21 18:57:27 | yselivanov | set | files:
+ getargspec.diff
messages:
+ msg243777 |
2014-04-30 08:09:16 | matrixise | set | messages:
+ msg217581 |
2014-04-16 23:17:25 | larry | set | messages:
+ msg216621 |
2014-04-15 21:21:00 | yselivanov | set | messages:
+ msg216387 |
2014-04-15 21:04:38 | ncoghlan | set | messages:
+ msg216385 |
2014-04-15 19:28:02 | matrixise | set | files:
+ issue20438_deprecate_inspect_getfullargspec-2.patch
messages:
+ msg216365 |
2014-04-15 17:28:29 | brett.cannon | set | messages:
+ msg216342 |
2014-04-15 17:09:53 | matrixise | set | messages:
+ msg216341 |
2014-04-15 17:07:30 | yselivanov | set | messages:
+ msg216340 |
2014-04-15 17:02:52 | matrixise | set | messages:
+ msg216339 |
2014-04-15 16:58:03 | brett.cannon | set | messages:
+ msg216337 |
2014-04-15 16:40:49 | matrixise | set | messages:
+ msg216333 |
2014-04-15 16:20:06 | yselivanov | set | messages:
+ msg216328 |
2014-04-15 16:16:35 | brett.cannon | set | messages:
+ msg216327 |
2014-04-15 15:47:48 | matrixise | set | messages:
+ msg216318 |
2014-04-15 15:47:22 | matrixise | set | files:
+ issue20438_deprecate_inspect-getfullargspec.patch
nosy:
+ matrixise messages:
+ msg216317
keywords:
+ patch |
2014-01-29 23:17:58 | yselivanov | set | versions:
+ Python 3.5, - Python 3.4 |
2014-01-29 23:17:29 | ncoghlan | set | messages:
+ msg209692 |
2014-01-29 18:28:51 | brett.cannon | set | messages:
+ msg209665 |
2014-01-29 18:28:28 | brett.cannon | set | messages:
+ msg209664 |
2014-01-29 17:00:13 | yselivanov | create | |