Fixed #29543 -- Fixed CPointerBase.__del__() ImportError crash.
This commit is contained in:
parent
f98e1c01ea
commit
66b6b68923
1
AUTHORS
1
AUTHORS
|
@ -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>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue