Opened 9 years ago

Closed 9 years ago

#2779 closed enhancement (fixed)

datastructures.MergeDict needs a copy() method

Reported by: limodou Owned by: adrian
Component: Core (Other) Version: master
Severity: normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description (last modified by adrian)

django.utils.datastructures.MergeDict does not have a copy() method.

request.REQUEST is an instance of MergeDict, so it's not possible to do request.REQUEST.copy().

Attachments (1)

2779.patch (1.6 KB) - added by chris.mcavoy@… 9 years ago.
Patch that adds shallow copy method to MergeDict

Download all attachments as: .zip

Change History (7)

comment:1 Changed 9 years ago by adrian

  • Description modified (diff)
  • Summary changed from request.REQUEST doesn't support copy() method to datastructures.MergeDict needs a copy() method

Changed summary and description.

comment:2 Changed 9 years ago by Simon G. <dev@…>

  • Triage Stage changed from Unreviewed to Accepted

Changed 9 years ago by chris.mcavoy@…

Patch that adds shallow copy method to MergeDict

comment:3 Changed 9 years ago by chris.mcavoy@…

  • Has patch set
  • Resolution set to fixed
  • Status changed from new to closed
  • Version set to SVN

Added copy and copy methods to MergeDict. Implements basic shallow copy. I didn't implement deepcopy, as I don't fully understand the role of memo in this documentation: http://www.python.org/doc/1.5.1p1/lib/module-copy.html

Also, it may be useful to change MergeDict to inherit from dict, rather than object. Most of the custom dicts in this module inherit from dict. I didn't know if there was a reason that MergeDict was different. If it's useful to convert MergeDict, I can do that.

I included some doctests in the file. This is my first patch to the project. Hurray for me!

comment:4 Changed 9 years ago by Simon G. <dev@…>

  • Resolution fixed deleted
  • Status changed from closed to reopened

Thanks Chris :) I've re-opened this so one of the core devs. can see it.

comment:5 Changed 9 years ago by Simon G. <dev@…>

  • Triage Stage changed from Accepted to Ready for checkin

comment:6 Changed 9 years ago by jacob

  • Resolution set to fixed
  • Status changed from reopened to closed

(In [4640]) Fixed #2779: added a copy() method to MergeDict, along with some new tests for django.utils.datastructures. Thanks, Chris McAvoy.

Note: See TracTickets for help on using tickets.
Back to Top