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/utils/datastructures.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'django/utils/datastructures.py') diff --git a/django/utils/datastructures.py b/django/utils/datastructures.py index 7713b08e8c..127c6dc774 100644 --- a/django/utils/datastructures.py +++ b/django/utils/datastructures.py @@ -1,6 +1,5 @@ import copy from collections import OrderedDict -from contextlib import suppress class OrderedSet: @@ -19,8 +18,10 @@ class OrderedSet: del self.dict[item] def discard(self, item): - with suppress(KeyError): + try: self.remove(item) + except KeyError: + pass def __iter__(self): return iter(self.dict) -- cgit v1.3