mirror of
https://github.com/django/django.git
synced 2025-09-27 04:29:17 +00:00
Fixed #28837 -- Fixed test client crash if an exception with more than one arg is raised.
Also removed usage of the problematic pattern elsewhere.
Regression in 6e55e1d88a
.
This commit is contained in:
parent
7a6fbf36b1
commit
746caf3ef8
6 changed files with 21 additions and 8 deletions
|
@ -4,7 +4,6 @@ The main QuerySet implementation. This provides the public API for the ORM.
|
|||
|
||||
import copy
|
||||
import operator
|
||||
import sys
|
||||
import warnings
|
||||
from collections import OrderedDict, namedtuple
|
||||
from functools import lru_cache
|
||||
|
@ -521,13 +520,12 @@ class QuerySet:
|
|||
params = {k: v() if callable(v) else v for k, v in params.items()}
|
||||
obj = self.create(**params)
|
||||
return obj, True
|
||||
except IntegrityError:
|
||||
exc_info = sys.exc_info()
|
||||
except IntegrityError as e:
|
||||
try:
|
||||
return self.get(**lookup), False
|
||||
except self.model.DoesNotExist:
|
||||
pass
|
||||
raise exc_info[0](exc_info[1]).with_traceback(exc_info[2])
|
||||
raise e
|
||||
|
||||
def _extract_model_params(self, defaults, **kwargs):
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue