This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: multiprocessing.Queue's put() signature differs from docs
Type: Stage: resolved
Components: Documentation Versions: Python 2.7, Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: orsenthil Nosy List: Erik.Cederstrand, docs@python, eli.bendersky, ezio.melotti, orsenthil, python-dev, westley.martinez
Priority: normal Keywords: patch

Created on 2011-02-09 00:35 by Erik.Cederstrand, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
multiprocessing-11155.diff westley.martinez, 2011-02-09 00:56 Replace obj with item. review
q.py Erik.Cederstrand, 2011-03-29 20:25 Script to compare the two Queue argspecs
doc-11155.diff westley.martinez, 2011-03-30 23:39 review
Messages (12)
msg128200 - (view) Author: Erik Cederstrand (Erik.Cederstrand) Date: 2011-02-09 00:35
In Python 2.6.6 on OSX:

>>> import inspect
>>> from multiprocessing import Queue
>>> q = Queue()
>>> print(inspect.getargspec(q.put))
ArgSpec(args=['self', 'obj', 'block', 'timeout'], varargs=None, keywords=None, defaults=(True, None))
>>> from Queue import Queue
>>> q = Queue()
>>> print(inspect.getargspec(q.put))
ArgSpec(args=['self', 'item', 'block', 'timeout'], varargs=None, keywords=None, defaults=(True, None))

Notice the 'obj' argument in the multiprocessing version and the 'item' argument in the Queue version. I think 'obj' should be renamed to 'item' to be in line with the other implementation and to agree with the docs: (http://docs.python.org/library/multiprocessing.html?highlight=multiprocessing#multiprocessing.Queue.put):

    put(item[, block[, timeout]])
msg128201 - (view) Author: Westley Martínez (westley.martinez) * Date: 2011-02-09 00:56
I've gone through Lib/multiproccing/queues.py and have replaced obj with item. Here's the patch.
msg132514 - (view) Author: Westley Martínez (westley.martinez) * Date: 2011-03-29 20:05
Well it's been quite some time and no response yet.
msg132520 - (view) Author: Erik Cederstrand (Erik.Cederstrand) Date: 2011-03-29 20:18
I'm not sure if I was supposed to respond. The patch looks straight-forward to me.
msg132522 - (view) Author: Erik Cederstrand (Erik.Cederstrand) Date: 2011-03-29 20:25
Just checked on Python 2.7.1 with the same result. Test script attached.
msg132575 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2011-03-30 08:12
Technically this is a backward-incompatible change, because it breaks code that uses obj=foo explicitly.
msg132622 - (view) Author: Westley Martínez (westley.martinez) * Date: 2011-03-30 23:39
In that case, I've made a patch that changes the documentation so that "item" is now "obj". for Queue.put and Queue.put_nowait.
msg133895 - (view) Author: Westley Martínez (westley.martinez) * Date: 2011-04-16 16:17
Can this patch be commited?
msg143500 - (view) Author: Westley Martínez (westley.martinez) * Date: 2011-09-05 00:59
¡Hola!
Just checking in.  The documentation is still incorrect for all versions.  There's a patch that fixes it ready to be reviewed.
msg143532 - (view) Author: Senthil Kumaran (orsenthil) * (Python committer) Date: 2011-09-05 15:49
anikom15's first patch seems correct. In the multiprocessing.py, the the arg 'obj' can be safely replaced with 'item' to be consistent with the docs. As this is not a keyword arg, it does not stand any chance of breaking any backwards compatibility. It looks me to that when multiprocessing' Queue.put was coding the first arg was wrongly mentioned as 'obj' instead of 'item'.

I shall commit the first patch unless someone objects to the above reasoning.
msg143543 - (view) Author: Senthil Kumaran (orsenthil) * (Python committer) Date: 2011-09-05 16:12
Well, I should take back my previous comment. I realized that the positional arg in this case can be called as keyword arg. It would be wrong to change multiprocessing.py and it is correct to change the docs.
msg143547 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-09-05 16:23
New changeset c6d4d4d64405 by Senthil Kumaran in branch '3.2':
Fix closes Issue11155  - Correct the multiprocessing.Queue.put's arg (replace 'item' with 'obj') in the docs. Patch by Westley Martínez.
http://hg.python.org/cpython/rev/c6d4d4d64405

New changeset 8f1187288fac by Senthil Kumaran in branch 'default':
merge from 3.2. Fix closes Issue11155  - Correct the multiprocessing.Queue.put's arg (replace 'item' with 'obj') in the docs. Patch by Westley Martínez.
http://hg.python.org/cpython/rev/8f1187288fac

New changeset d29c9006d770 by Senthil Kumaran in branch '2.7':
merge from 3.2.  Fix closes Issue11155  - Correct the multiprocessing.Queue.put's arg (replace 'item' with 'obj') in the docs. Patch by Westley Martínez.
http://hg.python.org/cpython/rev/d29c9006d770
History
Date User Action Args
2022-04-11 14:57:12adminsetgithub: 55364
2011-09-05 16:23:58python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg143547

resolution: fixed
stage: resolved
2011-09-05 16:12:21orsenthilsetmessages: + msg143543
2011-09-05 15:49:48orsenthilsetassignee: docs@python -> orsenthil

messages: + msg143532
nosy: + orsenthil
2011-09-05 02:32:40eli.benderskysetnosy: + eli.bendersky
2011-09-05 00:59:24westley.martinezsetmessages: + msg143500
2011-04-16 16:17:26westley.martinezsetmessages: + msg133895
2011-03-30 23:39:22westley.martinezsetfiles: + doc-11155.diff

messages: + msg132622
2011-03-30 08:12:10ezio.melottisetmessages: + msg132575
2011-03-29 20:26:18Erik.Cederstrandsetversions: + Python 2.7
2011-03-29 20:25:34Erik.Cederstrandsetfiles: + q.py

messages: + msg132522
2011-03-29 20:19:11ezio.melottisetnosy: + ezio.melotti
2011-03-29 20:18:17Erik.Cederstrandsetmessages: + msg132520
2011-03-29 20:05:32westley.martinezsetmessages: + msg132514
2011-02-09 00:56:04westley.martinezsetfiles: + multiprocessing-11155.diff

nosy: + westley.martinez
messages: + msg128201

keywords: + patch
2011-02-09 00:35:46Erik.Cederstrandcreate