[issue26202] The range() object is deepcopied as atomic
Serhiy Storchaka
report at bugs.python.org
Mon Jan 25 15:53:06 EST 2016
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 <report at bugs.python.org>
<http://bugs.python.org/issue26202>
_______________________________________
More information about the Python-bugs-list
mailing list