From 25209715d44562dcbf26f04ed9e0d19ee3c2aa84 Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Thu, 24 Apr 2014 08:41:37 +0200 Subject: [PATCH] Prevented a crash in the cursor wrappers on Oracle. Fixed #22483 (again). Forwardport of 5cd6429620 from stable/1.7.x --- django/db/backends/utils.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/django/db/backends/utils.py b/django/db/backends/utils.py index 738a05c9af..8078af9f95 100644 --- a/django/db/backends/utils.py +++ b/django/db/backends/utils.py @@ -36,8 +36,12 @@ class CursorWrapper(object): def __exit__(self, type, value, traceback): # Ticket #17671 - Close instead of passing thru to avoid backend - # specific behavior. - self.close() + # specific behavior. Catch errors liberally because errors in cleanup + # code aren't useful. + try: + self.close() + except self.db.Database.Error: + pass # The following methods cannot be implemented in __getattr__, because the # code must run when the method is invoked, not just when it is accessed.