
This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.
Created on2017-05-26 16:17 bypitrou, last changed2022-04-11 14:58 byadmin. This issue is nowclosed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 1840 | merged | lisroach,2017-05-28 05:00 | |
| PR 3668 | merged | vstinner,2017-09-20 13:01 | |
| Messages (10) | |||
|---|---|---|---|
| msg294554 -(view) | Author: Antoine Pitrou (pitrou)*![]() | Date: 2017-05-26 16:17 | |
There are use cases for setting a cell value. One such use case is for (un)pickling recursive closures (see heroic workaround here:https://github.com/cloudpipe/cloudpickle/pull/90/files#diff-d2a3618afedd4e124c532151eedbae09R74 ). Other use cases may include tinkering around and general education value.There also doesn't seem to be, AFAICS, any counter-indication to being able to do so. It's already possible in C using PyCell_Set(), which is a public API. It just lacks an API in Python land. For example `cell_contents` could become a read/write property... | |||
| msg294573 -(view) | Author: Lisa Roach (lisroach)*![]() | Date: 2017-05-27 01:14 | |
This idea makes sense to me. I'll see if I can put together the code for it. | |||
| msg294577 -(view) | Author: Raymond Hettinger (rhettinger)*![]() | Date: 2017-05-27 03:08 | |
+1 I don't see any reason this can't be writeable. | |||
| msg294583 -(view) | Author: Alyssa Coghlan (ncoghlan)*![]() | Date: 2017-05-27 06:14 | |
+1 from me, as this also has potential value in testing use cases and in dealing with some of the consequences of the zero-arg super() design (i.e. it will make the injected __class__ cell writable) | |||
| msg295057 -(view) | Author: Terry J. Reedy (terry.reedy)*![]() | Date: 2017-06-02 22:00 | |
A possible counter-indication would be if setting a cell could cause a crash, as opposed to a mysterious exception. Since 3.x already allows writing any object to a cell from python code, def outer(): cell = None def inner(ob): nonlocal cell cell = ob # rebinds <hidden-cell>.cell_contents return innerset_cell = outer()print(set_cell.__closure__[0].cell_contents) # Noneset_cell('something')print(set_cell.__closure__[0].cell_contents) # 'something'making "cell.cell_contents = 'something'" legal should not enable more crashes.I think that "function.__closure__[i].cell_contents = object" is perhaps not a good idea for production code, but I think it falls within the realm of 'consenting adults code' for the other uses suggested above. How should it be documented? | |||
| msg295058 -(view) | Author: Antoine Pitrou (pitrou)*![]() | Date: 2017-06-02 22:01 | |
There's already a documentation change to the PR, you can leave your comments there. | |||
| msg295416 -(view) | Author: Serhiy Storchaka (serhiy.storchaka)*![]() | Date: 2017-06-08 11:43 | |
New changeset64505a1f6c0af4574e17e823b27ffe24eca44df5 by Serhiy Storchaka (Lisa Roach) in branch 'master':bpo-30486: Allow setting cell value (#1840)https://github.com/python/cpython/commit/64505a1f6c0af4574e17e823b27ffe24eca44df5 | |||
| msg295417 -(view) | Author: Serhiy Storchaka (serhiy.storchaka)*![]() | Date: 2017-06-08 11:45 | |
Thank you for your contribution Lisa! | |||
| msg295476 -(view) | Author: Lisa Roach (lisroach)*![]() | Date: 2017-06-09 01:22 | |
Thank you for you guidance, Serhiy!On Thu, Jun 8, 2017 at 4:45 AM, Serhiy Storchaka <report@bugs.python.org>wrote:>> Serhiy Storchaka added the comment:>> Thank you for your contribution Lisa!>> ----------> resolution: -> fixed> stage: patch review -> resolved> status: open -> closed>> _______________________________________> Python tracker <report@bugs.python.org>> <http://bugs.python.org/issue30486>> _______________________________________> | |||
| msg302617 -(view) | Author: STINNER Victor (vstinner)*![]() | Date: 2017-09-20 13:54 | |
New changeset0ad05c32cc41d4c21bfd78b9ffead519ead475a2 by Victor Stinner in branch 'master':bpo-30486: Make cell_set_contents() symbol private (#3668)https://github.com/python/cpython/commit/0ad05c32cc41d4c21bfd78b9ffead519ead475a2 | |||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:58:46 | admin | set | github: 74671 |
| 2017-09-20 13:54:17 | vstinner | set | nosy: +vstinner messages: +msg302617 |
| 2017-09-20 13:01:39 | vstinner | set | pull_requests: +pull_request3658 |
| 2017-06-09 02:26:34 | gvanrossum | set | nosy: -gvanrossum |
| 2017-06-09 01:22:47 | lisroach | set | messages: +msg295476 |
| 2017-06-08 11:45:01 | serhiy.storchaka | set | status: open -> closed resolution: fixed messages: +msg295417 stage: patch review -> resolved |
| 2017-06-08 11:43:28 | serhiy.storchaka | set | nosy: +serhiy.storchaka messages: +msg295416 |
| 2017-06-02 22:01:10 | pitrou | set | messages: +msg295058 |
| 2017-06-02 22:00:27 | terry.reedy | set | nosy: +terry.reedy messages: +msg295057 stage: needs patch -> patch review |
| 2017-05-28 05:00:15 | lisroach | set | pull_requests: +pull_request1925 |
| 2017-05-27 06:14:28 | ncoghlan | set | messages: +msg294583 |
| 2017-05-27 03:09:04 | rhettinger | set | assignee:lisroach |
| 2017-05-27 03:08:48 | rhettinger | set | messages: +msg294577 |
| 2017-05-27 01:14:17 | lisroach | set | nosy: +lisroach messages: +msg294573 |
| 2017-05-26 17:03:20 | Jim Fasarakis-Hilliard | set | nosy: +Jim Fasarakis-Hilliard |
| 2017-05-26 16:17:01 | pitrou | create | |