#34484: HttpRequest.__deepcopy__ doesn't deepcopy attributes
-------------------------------------------+------------------------
               Reporter:  Adam Johnson     |          Owner:  nobody
                   Type:  Bug              |         Status:  new
              Component:  HTTP handling    |        Version:  4.2
               Severity:  Release blocker  |       Keywords:
           Triage Stage:  Unreviewed       |      Has patch:  0
    Needs documentation:  0                |    Needs tests:  0
Patch needs improvement:  0                |  Easy pickings:  0
                  UI/UX:  0                |
-------------------------------------------+------------------------
 Regression in Django 4.2. Deepcopying a HttpRequest no longer deepcopies
 its attributes, including attached ones like `session`.

 Leads to test pollution where a request is created in setUpTestData, for
 example:

 {{{
 from django.test import TestCase
 from django.test import RequestFactory


 class ExampleTests(TestCase):
     @classmethod
     def setUpTestData(cls):
         cls.request = RequestFactory().get("/")
         cls.request.session = {}

     def test_adding(self):
         self.request.session["foo"] = 1
         self.assertEqual(self.request.session, {"foo": 1})

     def test_looking(self):
         self.assertEqual(self.request.session, {})
 }}}

 (Simplified from a real test suite.)

 Bisected to #29186 / 6220c445c40a6a7f4d442de8bde2628346153963, using these
 commands to run the above test case:

 {{{
 git bisect start facc153af7 ff8e5eacda
 git bisect run sh -c 'cd tests && ./runtests.py test_regression -v 2'
 }}}

 I see #34482 was also just opened as a regression from that same ticket.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34484>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018770b57f5c-e1da0687-bb2a-4403-bf0d-ed8df82985b3-000000%40eu-central-1.amazonses.com.

Reply via email to