classification
Title: Add PEP 8 compliant aliases to threading module
Type: enhancement Stage:
Components: Library (Lib) Versions: Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Rhamphoryncus, benjamin.peterson, ncoghlan
Priority: high Keywords: patch

Created on 2008-06-05 12:56 by ncoghlan, last changed 2008-06-11 19:45 by benjamin.peterson. 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: Nick 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: Nick 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: Nick 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
2008-06-11 19:45:29benjamin.petersonsetstatus: open -> closed
resolution: fixed
messages: + msg68011
2008-06-10 21:13:15benjamin.petersonsetfiles: + new_threading_api3.patch
messages: + msg67923
2008-06-09 06:35:48ncoghlansetmessages: + msg67858
2008-06-06 13:09:41benjamin.petersonlinkissue3050 dependencies
2008-06-06 02:28:35Rhamphoryncussetnosy: + Rhamphoryncus
2008-06-06 02:03:35benjamin.petersonsetmessages: + msg67745
2008-06-06 01:56:11ncoghlansetmessages: + msg67743
2008-06-05 15:58:37benjamin.petersonsetfiles: + new_threading_api2.patch
messages: + msg67717
2008-06-05 15:12:18benjamin.petersonsetfiles: + new_threading_api.patch
keywords: + patch
messages: + msg67715
nosy: + benjamin.peterson
2008-06-05 12:56:01ncoghlancreate