Issue 3042: Add PEP 8 compliant aliases to threading module (original) (raw)

Created on 2008-06-05 12:56 by ncoghlan, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
new_threading_api.patch benjamin.peterson,2008-06-05 15:12
new_threading_api2.patch benjamin.peterson,2008-06-05 15:58
new_threading_api3.patch benjamin.peterson,2008-06-10 21:13
Messages (8)
msg67711 - (view) Author: Alyssa Coghlan (ncoghlan) * (Python committer) Date: 2008-06-05 12:55
PEP 371 highlighted the non-PEP 8 compliant nature of the threading API. Since part of that PEP involves updating the multiprocessing API to be PEP 8 compliant before addition the standard library, the threading API should also be updated to be PEP 8 compliant in 3.0. That part's easy - the trickier part if to provide both the existing API and a PEP 8 compliant API in 2.6, with the old names triggering a warning when run with the -3 switch, but not suffering a performance hit otherwise. The trick with that is to define the renamed API's differently depending on whether or not sys.py3kwarning is set, rather than checking it every time the old APIs are invoked. (Left unassigned for the moment, since I'm about to go completely offline for a few days, so it will be tough for me to get to this before the first beta)
msg67715 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2008-06-05 15:12
Is this what you were looking for? (in the patch) What I did could also be done with metaclasses, but I thought that would be overkill. Warning: this patch causes test threading to crash when run with the -3 flag.
msg67717 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2008-06-05 15:58
Attaching a patch which fixes everything.
msg67743 - (view) Author: Alyssa Coghlan (ncoghlan) * (Python committer) Date: 2008-06-06 01:56
The code changes in the patch look pretty good to me (although you probably want to actually use @wraps inside _old_api!) There are obviously also documentation and test suite changes that will be needed.
msg67745 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2008-06-06 02:03
On Thu, Jun 5, 2008 at 8:56 PM, Nick Coghlan <report@bugs.python.org> wrote: > > Nick Coghlan <ncoghlan@gmail.com> added the comment: > > The code changes in the patch look pretty good to me (although you > probably want to actually use @wraps inside _old_api!) That won't work because we are creating the method than we would pass to wraps. Changing old's __name__ to old_name should do the trick. > > There are obviously also documentation and test suite changes that will > be needed. Of course. I can do that.
msg67858 - (view) Author: Alyssa Coghlan (ncoghlan) * (Python committer) Date: 2008-06-09 06:35
I'd still be inclined to put a @wraps(meth) decorator on the definition of the wrapper function (and then override to the supplied name afterwards) - remember that functools.wraps is a decorator factory rather than a decorator itself. That would ensure that any docstrings and the like would be preserved (granted, it appears the threading module currently doesn't *have* any docstrings, but it would still be better to write the wrapping code correctly).
msg67923 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2008-06-10 21:13
Ok. Pending your acceptance, I'll apply after docs+tests.
msg68011 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2008-06-11 19:45
Applied in r64125, and r64144.
History
Date User Action Args
2022-04-11 14:56:35 admin set github: 47292
2008-06-11 19:45:29 benjamin.peterson set status: open -> closedresolution: fixedmessages: +
2008-06-10 21:13:15 benjamin.peterson set files: + new_threading_api3.patchmessages: +
2008-06-09 06:35:48 ncoghlan set messages: +
2008-06-06 13:09:41 benjamin.peterson link issue3050 dependencies
2008-06-06 02:28:35 Rhamphoryncus set nosy: + Rhamphoryncus
2008-06-06 02:03:35 benjamin.peterson set messages: +
2008-06-06 01:56:11 ncoghlan set messages: +
2008-06-05 15:58:37 benjamin.peterson set files: + new_threading_api2.patchmessages: +
2008-06-05 15:12:18 benjamin.peterson set files: + new_threading_api.patchkeywords: + patchmessages: + nosy: + benjamin.peterson
2008-06-05 12:56:01 ncoghlan create