diff options
| author | Mushtaq Ali <mushtaque.ali@arbisoft.com> | 2018-07-06 20:26:14 +0500 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2018-07-06 11:26:14 -0400 |
| commit | 66b6b689239dad3f017d2a3495df748cbee5debb (patch) | |
| tree | 30b866674ba72e6a4c206f864b168fe66ac43f51 | |
| parent | f98e1c01eafa724cb87772ae03b3fd1158e9fd50 (diff) | |
Fixed #29543 -- Fixed CPointerBase.__del__() ImportError crash.
| -rw-r--r-- | AUTHORS | 1 | ||||
| -rw-r--r-- | django/contrib/gis/ptr.py | 2 | ||||
| -rw-r--r-- | tests/gis_tests/test_ptr.py | 8 |
3 files changed, 10 insertions, 1 deletions
@@ -602,6 +602,7 @@ answer newbie questions, and generally made Django that much better: Morten Bagai <m@bagai.com> msaelices <msaelices@gmail.com> msundstr + Mushtaq Ali <mushtaak@gmail.com> Mykola Zamkovoi <nickzam@gmail.com> Nagy Károly <charlie@rendszergazda.com> Nasimul Haque <nasim.haque@gmail.com> diff --git a/django/contrib/gis/ptr.py b/django/contrib/gis/ptr.py index afc83fdd22..a5a117a19a 100644 --- a/django/contrib/gis/ptr.py +++ b/django/contrib/gis/ptr.py @@ -34,5 +34,5 @@ class CPointerBase: if self.destructor and self._ptr: try: self.destructor(self.ptr) - except (AttributeError, TypeError): + except (AttributeError, ImportError, TypeError): pass # Some part might already have been garbage collected diff --git a/tests/gis_tests/test_ptr.py b/tests/gis_tests/test_ptr.py index ca318a28eb..1d80e24f92 100644 --- a/tests/gis_tests/test_ptr.py +++ b/tests/gis_tests/test_ptr.py @@ -64,3 +64,11 @@ class CPointerBaseTests(SimpleTestCase): fg.ptr = ptr del fg destructor_mock.assert_called_with(ptr) + + def test_destructor_catches_importerror(self): + class FakeGeom(CPointerBase): + destructor = mock.Mock(side_effect=ImportError) + + fg = FakeGeom() + fg.ptr = fg.ptr_type(1) + del fg |
