You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee='https://github.com/serhiy-storchaka'closed_at=<Date2016-01-28.19:46:46.805>created_at=<Date2016-01-25.20:53:06.176>labels= ['type-bug', 'library']
title='The range() object is deepcopied as atomic'updated_at=<Date2020-05-28.08:15:50.321>user='https://github.com/serhiy-storchaka'
New changeset 5f4b229 by Serhiy Storchaka in branch 'master': bpo-40792: Make the result of PyNumber_Index() always having exact type int. (GH-20443) 5f4b229
Activity
serhiy-storchaka commentedon Jan 25, 2016
The range() object is immutable, but is not atomic, and copy.deepcopy() shouldn't return it unchanged.
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.
vstinner commentedon Jan 25, 2016
Hum ok, it's a bug :-) It should be fixed. Do you want to work on a patch?
ethanfurman commentedon Jan 25, 2016
I don't have much experience with the copy module, but I don't see any problems with the code.
Does copy.copy suffer from the same problem? If yes, is it fixed with this same patch, or is more work needed?
ethanfurman commentedon Jan 25, 2016
Victor, patch was already attached. ;)
vstinner commentedon Jan 25, 2016
deepcopy_range.patch looks good to me.
serhiy-storchaka commentedon Jan 25, 2016
Returning the same range() object from copy.copy() is correct. This is shallow copying.
python-dev commentedon Jan 28, 2016
New changeset 5772eae17a82 by Serhiy Storchaka in branch '3.5':
Issue bpo-26202: copy.deepcopy() now correctly copies range() objects with
https://hg.python.org/cpython/rev/5772eae17a82
New changeset d5d0b62c2830 by Serhiy Storchaka in branch 'default':
Issue bpo-26202: copy.deepcopy() now correctly copies range() objects with
https://hg.python.org/cpython/rev/d5d0b62c2830
serhiy-storchaka commentedon Jan 28, 2016
Thanks Victor.
serhiy-storchaka commentedon May 28, 2020
New changeset 5f4b229 by Serhiy Storchaka in branch 'master':
bpo-40792: Make the result of PyNumber_Index() always having exact type int. (GH-20443)
5f4b229
serhiy-storchaka commentedon May 28, 2020
This change has been reverted in bpo-40792. The range object attributes has now exact type int, so the original issue with deep copying is gone.