﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
21740	client.py uses mutable default arguments, which is bad practice	sleepydragon	anonymous	"In django/test/client.py there are several methods that have data={} in their argument lists.  The {} dictionary is a mutable type and it is not recommended to use mutable objects as default arguments.  This is because each invocation of the method where data is not specified will use the same dict object.  This enables completely unrelated method calls to affect each other.

The fix that I recommend is to instead use data=None in the argument list for the affected methods and then in the method body check for None and create a new dict if it is None.  That way each method invocation gets their own, local dict object.  I have attached a patch for review.

I'm fairly new to Django so it's possible that data=None is actually a meaningful value.  If that is the case then this approach will need to be tweaked a bit."	Cleanup/optimization	closed	Testing framework	dev	Normal	fixed			Ready for checkin	1	0	0	0	1	0
