Przeglądaj źródła

Deepcopy should not cause a recursion error on the ProductAttributesC… (#4018)

* Deepcopy should not cause a recursion error on the ProductAttributesContainer
master
Voxin Muyli 2 lat temu
rodzic
commit
c4ebfa680f
No account linked to committer's email address

+ 3
- 0
src/oscar/apps/catalogue/product_attributes.py Wyświetl plik

16
     """
16
     """
17
 
17
 
18
     def __setstate__(self, state):
18
     def __setstate__(self, state):
19
+        self.__dict__.setdefault("_product", None)
20
+        self.__dict__.setdefault("_initialized", False)
21
+        self.__dict__.setdefault("_dirty", set())
19
         self.__dict__ = state
22
         self.__dict__ = state
20
 
23
 
21
     def __init__(self, product):
24
     def __init__(self, product):

+ 7
- 0
tests/unit/catalogue/test_product_attributes.py Wyświetl plik

1
+from copy import deepcopy
2
+
1
 from django.core.exceptions import ValidationError
3
 from django.core.exceptions import ValidationError
2
 from django.test import TestCase
4
 from django.test import TestCase
3
 
5
 
167
             "so it saved, even when the parent has the same value",
169
             "so it saved, even when the parent has the same value",
168
         )
170
         )
169
 
171
 
172
+    def test_deepcopy(self):
173
+        "Deepcopy should not cause a recursion error"
174
+        deepcopy(self.product)
175
+        deepcopy(self.child_product)
176
+
170
 
177
 
171
 class ProductAttributeQuerysetTest(TestCase):
178
 class ProductAttributeQuerysetTest(TestCase):
172
     fixtures = ["productattributes"]
179
     fixtures = ["productattributes"]

Ładowanie…
Anuluj
Zapisz