From 9811a29a5a1348f1a5de30a9a7a5d0f8d2fd4843 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Thu, 9 May 2019 11:20:33 +0300 Subject: [PATCH] Pass through memo in __deepcopy__ as required by the docs (#6660) This is needed to avoid problems with recursive loops. See https://docs.python.org/3.7/library/copy.html toward the end. --- rest_framework/fields.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rest_framework/fields.py b/rest_framework/fields.py index e2fb8cdc6..aecfa3302 100644 --- a/rest_framework/fields.py +++ b/rest_framework/fields.py @@ -614,7 +614,7 @@ class Field: for item in self._args ] kwargs = { - key: (copy.deepcopy(value) if (key not in ('validators', 'regex')) else value) + key: (copy.deepcopy(value, memo) if (key not in ('validators', 'regex')) else value) for key, value in self._kwargs.items() } return self.__class__(*args, **kwargs)