[pypy-commit] pypy stdlib-2.7.12: include "__del__" in old style classes' error message

pjenvey pypy.commits at gmail.com
Sat Oct 8 19:27:27 EDT 2016


Author: Philip Jenvey <pjenvey at underboss.org>
Branch: stdlib-2.7.12
Changeset: r87640:67896f62ff21
Date: 2016-10-08 16:26 -0700
http://bitbucket.org/pypy/pypy/changeset/67896f62ff21/

Log:	include "__del__" in old style classes' error message

diff --git a/pypy/module/__builtin__/interp_classobj.py b/pypy/module/__builtin__/interp_classobj.py
--- a/pypy/module/__builtin__/interp_classobj.py
+++ b/pypy/module/__builtin__/interp_classobj.py
@@ -1,5 +1,6 @@
 import new
 from pypy.interpreter.error import OperationError, oefmt
+from pypy.interpreter.executioncontext import report_error
 from pypy.interpreter.gateway import interp2app, unwrap_spec
 from pypy.interpreter.typedef import TypeDef, make_weakref_descr
 from pypy.interpreter.baseobjspace import W_Root
@@ -656,9 +657,13 @@
         if w_func is None:
             w_func = self.getattr_from_class(space, '__del__')
         if w_func is not None:
-            if self.space.user_del_action.gc_disabled(self):
+            if space.user_del_action.gc_disabled(self):
                 return
-            space.call_function(w_func)
+            try:
+                space.call_function(w_func)
+            except Exception as e:
+                # report this came from __del__ vs a generic finalizer
+                report_error(space, e, "method __del__ of ", self)
 
     def descr_exit(self, space, w_type, w_value, w_tb):
         w_func = self.getattr(space, '__exit__', False)


More information about the pypy-commit mailing list