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.

Author terry.reedy
Recipients Jim Fasarakis-Hilliard, benjamin.peterson, gvanrossum, lisroach, ncoghlan, pitrou, rhettinger, terry.reedy
Date 2017-06-02.22:00:26
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1496440827.1.0.403865012729.issue30486@psf.upfronthosting.co.za>
In-reply-to
Content
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 inner

set_cell = outer()
print(set_cell.__closure__[0].cell_contents)  # None
set_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?
History
Date User Action Args
2017-06-02 22:00:27terry.reedysetrecipients: + terry.reedy, gvanrossum, rhettinger, ncoghlan, pitrou, benjamin.peterson, lisroach, Jim Fasarakis-Hilliard
2017-06-02 22:00:27terry.reedysetmessageid: <1496440827.1.0.403865012729.issue30486@psf.upfronthosting.co.za>
2017-06-02 22:00:26terry.reedylinkissue30486 messages
2017-06-02 22:00:26terry.reedycreate