New submission from Serhiy Storchaka: The range() object is immutable, but is not atomic, and copy.deepcopy() shouldn't return it unchanged.
>>> class I(int): pass # mutable index ... >>> import copy >>> r = range(I(10)) >>> r2 = copy.deepcopy(r) >>> r.stop.attr = 'spam' >>> r2.stop.attr 'spam' This is Python 3 only issue because in 2.7 the xrange() object doesn't exposes start/stop/step attributes. Proposed patch fixes the copy module. ---------- components: Library (Lib) files: deepcopy_range.patch keywords: patch messages: 258921 nosy: alexandre.vassalotti, fdrake, haypo, serhiy.storchaka priority: normal severity: normal stage: patch review status: open title: The range() object is deepcopied as atomic type: behavior versions: Python 3.5, Python 3.6 Added file: http://bugs.python.org/file41714/deepcopy_range.patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26202> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com