[pypy-commit] pypy default: A bit more care about __del__ on half-initialized instances

arigo noreply at buildbot.pypy.org
Sun Jun 7 22:00:10 CEST 2015


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r77944:4156be89b516
Date: 2015-06-07 22:00 +0200
http://bitbucket.org/pypy/pypy/changeset/4156be89b516/

Log:	A bit more care about __del__ on half-initialized instances

diff --git a/pypy/module/_multiprocessing/interp_connection.py b/pypy/module/_multiprocessing/interp_connection.py
--- a/pypy/module/_multiprocessing/interp_connection.py
+++ b/pypy/module/_multiprocessing/interp_connection.py
@@ -28,6 +28,7 @@
 
 class W_BaseConnection(W_Root):
     BUFFER_SIZE = 1024
+    buffer = lltype.nullptr(rffi.CCHARP.TO)
 
     def __init__(self, flags):
         self.flags = flags
@@ -35,7 +36,8 @@
                                     flavor='raw')
 
     def __del__(self):
-        lltype.free(self.buffer, flavor='raw')
+        if self.buffer:
+            lltype.free(self.buffer, flavor='raw')
         try:
             self.do_close()
         except OSError:
@@ -204,6 +206,7 @@
 
 class W_FileConnection(W_BaseConnection):
     INVALID_HANDLE_VALUE = -1
+    fd = INVALID_HANDLE_VALUE
 
     if sys.platform == 'win32':
         def WRITE(self, data):


More information about the pypy-commit mailing list