From 280ca147af9cdfce1ca9cb14cc3c5527ff6c7a02 Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Wed, 12 Apr 2023 09:25:45 +0200 Subject: Fixed #34484, Refs #34482 -- Reverted "Fixed #29186 -- Fixed pickling HttpRequest and subclasses." MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 6220c445c40a6a7f4d442de8bde2628346153963. Thanks Adam Johnson and Márton Salomváry for reports. --- django/core/handlers/wsgi.py | 10 ---------- django/http/request.py | 17 ----------------- django/http/response.py | 2 ++ 3 files changed, 2 insertions(+), 27 deletions(-) (limited to 'django') diff --git a/django/core/handlers/wsgi.py b/django/core/handlers/wsgi.py index c2b7cc2b6f..9324af083e 100644 --- a/django/core/handlers/wsgi.py +++ b/django/core/handlers/wsgi.py @@ -54,9 +54,6 @@ class LimitedStream(IOBase): class WSGIRequest(HttpRequest): - non_picklable_attrs = HttpRequest.non_picklable_attrs | frozenset(["environ"]) - meta_non_picklable_attrs = frozenset(["wsgi.errors", "wsgi.input"]) - def __init__(self, environ): script_name = get_script_name(environ) # If PATH_INFO is empty (e.g. accessing the SCRIPT_NAME URL without a @@ -82,13 +79,6 @@ class WSGIRequest(HttpRequest): self._read_started = False self.resolver_match = None - def __getstate__(self): - state = super().__getstate__() - for attr in self.meta_non_picklable_attrs: - if attr in state["META"]: - del state["META"][attr] - return state - def _get_scheme(self): return self.environ.get("wsgi.url_scheme") diff --git a/django/http/request.py b/django/http/request.py index 2ef9dfd649..be6823cacb 100644 --- a/django/http/request.py +++ b/django/http/request.py @@ -55,8 +55,6 @@ class HttpRequest: _encoding = None _upload_handlers = [] - non_picklable_attrs = frozenset(["resolver_match", "_stream"]) - def __init__(self): # WARNING: The `WSGIRequest` subclass doesn't call `super`. # Any variable assignment made here should also happen in @@ -84,21 +82,6 @@ class HttpRequest: self.get_full_path(), ) - def __getstate__(self): - obj_dict = self.__dict__.copy() - for attr in self.non_picklable_attrs: - if attr in obj_dict: - del obj_dict[attr] - return obj_dict - - def __deepcopy__(self, memo): - obj = copy.copy(self) - for attr in self.non_picklable_attrs: - if hasattr(self, attr): - setattr(obj, attr, copy.deepcopy(getattr(self, attr), memo)) - memo[id(self)] = obj - return obj - @cached_property def headers(self): return HttpHeaders(self.META) diff --git a/django/http/response.py b/django/http/response.py index 3b611e78f5..58993801e1 100644 --- a/django/http/response.py +++ b/django/http/response.py @@ -373,10 +373,12 @@ class HttpResponse(HttpResponseBase): [ "resolver_match", # Non-picklable attributes added by test clients. + "asgi_request", "client", "context", "json", "templates", + "wsgi_request", ] ) -- cgit v1.2.1