﻿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
34484	HttpRequest.__deepcopy__ doesn't deepcopy attributes	Adam Johnson	Mariusz Felisiak	"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, {})
}}}

Leading to:

{{{
test_adding (test_regression.ExampleTests.test_adding) ... ok
test_looking (test_regression.ExampleTests.test_looking) ... FAIL

======================================================================
FAIL: test_looking (test_regression.ExampleTests.test_looking)
----------------------------------------------------------------------
Traceback (most recent call last):
  File ""/Users/chainz/Documents/Projects/django/tests/test_regression.py"", line 16, in test_looking
    self.assertEqual(self.request.session, {})
AssertionError: {'foo': 1} != {}
- {'foo': 1}
+ {}
}}}

(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."	Bug	closed	HTTP handling	4.2	Release blocker	fixed			Accepted	1	0	0	0	0	0
