From 6e4c6281dbb7ee12bcdc22620894edb4e9cf623f Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Thu, 7 Sep 2017 08:16:21 -0400 Subject: Reverted "Fixed #27818 -- Replaced try/except/pass with contextlib.suppress()." This reverts commit 550cb3a365dee4edfdd1563224d5304de2a57fda because try/except performs better. --- django/db/models/sql/query.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'django/db/models/sql') diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index 509d97e65d..017edea873 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -7,7 +7,6 @@ databases). The abstraction barrier only works one way: this module has to know all about the internals of models in order to get the information it needs. """ from collections import Counter, Iterator, Mapping, OrderedDict, namedtuple -from contextlib import suppress from itertools import chain, count, product from string import ascii_uppercase @@ -313,8 +312,10 @@ class Query: obj.subq_aliases = self.subq_aliases.copy() obj.used_aliases = self.used_aliases.copy() # Clear the cached_property - with suppress(AttributeError): + try: del obj.base_table + except AttributeError: + pass return obj def chain(self, klass=None): -- cgit v1.3