Author: Antonio Cuni <anto.c...@gmail.com>
Branch: resource_warning
Changeset: r83551:110eae852734
Date: 2016-04-06 19:39 +0000
http://bitbucket.org/pypy/pypy/changeset/110eae852734/

Log:    move the logic from __del__ to destructor, because we are not
        allowed to call arbitrary code from the interp-level __del__

diff --git a/pypy/module/_file/interp_file.py b/pypy/module/_file/interp_file.py
--- a/pypy/module/_file/interp_file.py
+++ b/pypy/module/_file/interp_file.py
@@ -49,15 +49,16 @@
         # thread that runs __del__, so no race condition should be possible
         self.clear_all_weakrefs()
         if self.stream is not None:
-            if self.space.sys.resource_warning_enabled:
-                w_repr = self.space.repr(self)
-                str_repr = self.space.str_w(w_repr)
-                self.space.resource_warning("WARNING: unclosed file: " + 
str_repr)
             self.enqueue_for_destruction(self.space, W_File.destructor,
                                          'close() method of ')
 
     def destructor(self):
         assert isinstance(self, W_File)
+        if self.space.sys.resource_warning_enabled:
+            w_repr = self.space.repr(self)
+            str_repr = self.space.str_w(w_repr)
+            self.space.resource_warning("WARNING: unclosed file: " + str_repr)
+        #
         try:
             self.direct_close()
         except StreamErrors, e:
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to