1
0
mirror of https://github.com/django/django.git synced 2024-12-22 17:16:24 +00:00

Fixed #29543 -- Fixed CPointerBase.__del__() ImportError crash.

This commit is contained in:
Mushtaq Ali 2018-07-06 20:26:14 +05:00 committed by Tim Graham
parent f98e1c01ea
commit 66b6b68923
3 changed files with 10 additions and 1 deletions

View File

@ -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>

View File

@ -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

View File

@ -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