From d4bc0bf435402f32d1e31aeffd280276349283d8 Mon Sep 17 00:00:00 2001 From: Mikhail Denisenko Date: Thu, 2 Oct 2014 21:58:36 -0400 Subject: [PATCH] Fixed #22879 -- Intercept errors coming from cursor.__next__() --- django/db/backends/utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/django/db/backends/utils.py b/django/db/backends/utils.py index 77132e3f25..a95255b862 100644 --- a/django/db/backends/utils.py +++ b/django/db/backends/utils.py @@ -29,7 +29,9 @@ class CursorWrapper(object): return cursor_attr def __iter__(self): - return iter(self.cursor) + with self.db.wrap_database_errors: + for item in self.cursor: + yield item def __enter__(self): return self