Skip to content

Commit d507cd8

Browse files
authored
Fix infinite recursion with deepcopy on Request (#8684)
1 parent c10f226 commit d507cd8

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

rest_framework/request.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,8 @@ def __getattr__(self, attr):
413413
to proxy it to the underlying HttpRequest object.
414414
"""
415415
try:
416-
return getattr(self._request, attr)
416+
_request = self.__getattribute__("_request")
417+
return getattr(_request, attr)
417418
except AttributeError:
418419
return self.__getattribute__(attr)
419420

tests/test_request.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Tests for content parsing, and form-overloaded content parsing.
33
"""
4+
import copy
45
import os.path
56
import tempfile
67

@@ -344,3 +345,10 @@ def test_duplicate_request_form_data_access(self):
344345
# ensure that request stream was consumed by form parser
345346
assert request.content_type.startswith('multipart/form-data')
346347
assert response.data == {'a': ['b']}
348+
349+
350+
class TestDeepcopy(TestCase):
351+
352+
def test_deepcopy_works(self):
353+
request = Request(factory.get('/', secure=False))
354+
copy.deepcopy(request)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy