summaryrefslogtreecommitdiff
path: root/django/db/models/query_utils.py
diff options
context:
space:
mode:
authorstarryrbs <1322096624@qq.com>2021-02-18 00:04:59 +0800
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2021-02-18 21:13:24 +0100
commit466920f6d726eee90d5566e0a9948e92b33a122e (patch)
tree2fca8e339e564a08c9e710072bd55d50700849cf /django/db/models/query_utils.py
parent1710cdbe79c90665046034fe1700933d038d90ad (diff)
downloaddjango-466920f6d726eee90d5566e0a9948e92b33a122e.tar.gz
Fixed #32450 -- Fixed crash when ANDing/ORing an empty Q() with not pickleable Q().
Regression in bb0b6e526340e638522e093765e534df4e4393d2.
Diffstat (limited to 'django/db/models/query_utils.py')
-rw-r--r--django/db/models/query_utils.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/django/db/models/query_utils.py b/django/db/models/query_utils.py
index c2623f099f..c957ffa564 100644
--- a/django/db/models/query_utils.py
+++ b/django/db/models/query_utils.py
@@ -5,7 +5,6 @@ Factored out from django.db.models.query to avoid making the main module very
large and/or so that they can be used by other modules without getting into
circular import difficulties.
"""
-import copy
import functools
import inspect
from collections import namedtuple
@@ -46,10 +45,12 @@ class Q(tree.Node):
# If the other Q() is empty, ignore it and just use `self`.
if not other:
- return copy.deepcopy(self)
+ _, args, kwargs = self.deconstruct()
+ return type(self)(*args, **kwargs)
# Or if this Q is empty, ignore it and just use `other`.
elif not self:
- return copy.deepcopy(other)
+ _, args, kwargs = other.deconstruct()
+ return type(other)(*args, **kwargs)
obj = type(self)()
obj.connector = conn