[pypy-svn] r51503 - pypy/dist/pypy/lib/_ctypes

fijal at codespeak.net fijal at codespeak.net
Fri Feb 15 09:51:57 CET 2008


Author: fijal
Date: Fri Feb 15 09:51:54 2008
New Revision: 51503

Modified:
   pypy/dist/pypy/lib/_ctypes/array.py
   pypy/dist/pypy/lib/_ctypes/basics.py
   pypy/dist/pypy/lib/_ctypes/pointer.py
   pypy/dist/pypy/lib/_ctypes/primitive.py
   pypy/dist/pypy/lib/_ctypes/structure.py
Log:
* Remove buggy keepalives.
* Rename __del__ to delete. Let's first figure out exact rules.


Modified: pypy/dist/pypy/lib/_ctypes/array.py
==============================================================================
--- pypy/dist/pypy/lib/_ctypes/array.py	(original)
+++ pypy/dist/pypy/lib/_ctypes/array.py	Fri Feb 15 09:51:54 2008
@@ -110,7 +110,6 @@
     def __init__(self, *args):
         self._buffer = self._ffiarray(self._length_)
         self._needs_free = True
-        self._objects = []
         for i, arg in enumerate(args):
             self[i] = arg
 
@@ -136,7 +135,6 @@
         if isinstance(index, slice):
             self._slice_setitem(index, value)
             return
-        self._objects.append(value) # keepalive value
         value = self._type_._CData_input(value)
         index = self._fix_index(index)
         if not isinstance(self._type_._ffishape, tuple):
@@ -160,7 +158,7 @@
     def _get_buffer_for_param(self):
         return self._buffer.byptr()
 
-    def __del__(self):
+    def delete(self):
         if self._needs_free:
             self._buffer.free()
             self._buffer = None

Modified: pypy/dist/pypy/lib/_ctypes/basics.py
==============================================================================
--- pypy/dist/pypy/lib/_ctypes/basics.py	(original)
+++ pypy/dist/pypy/lib/_ctypes/basics.py	Fri Feb 15 09:51:54 2008
@@ -99,7 +99,6 @@
     # fix the address, in case it's unsigned
     address = address & (sys.maxint * 2 + 1)
     instance = self.__new__(self)
-    instance._objects = []
     lgt = getattr(self, '_length_', 1)
     instance._buffer = self._ffiarray.fromaddress(address, lgt)
     return instance

Modified: pypy/dist/pypy/lib/_ctypes/pointer.py
==============================================================================
--- pypy/dist/pypy/lib/_ctypes/pointer.py	(original)
+++ pypy/dist/pypy/lib/_ctypes/pointer.py	Fri Feb 15 09:51:54 2008
@@ -56,7 +56,6 @@
         def __init__(self, value=None):
             self._buffer = ffiarray(1)
             self._needs_free = True
-            self._objects = [value] # keepalive value
             if value is not None:
                 self.contents = value
         self._ffiarray = ffiarray
@@ -80,7 +79,6 @@
             raise TypeError("expected %s instead of %s" % (
                 self._type_.__name__, type(value).__name__))
         value = value._buffer
-        self._objects = [value]
         self._buffer[0] = value
 
     _get_slice_params = array_get_slice_params
@@ -99,13 +97,12 @@
         return self._type_._CData_output(self._subarray(index))
 
     def __setitem__(self, index, value):
-        self._objects = [value]
         self._subarray(index)[0] = self._type_._CData_input(value)[0]
 
     def __nonzero__(self):
         return self._buffer[0] != 0
 
-    def __del__(self):
+    def delete(self):
         if self._needs_free:
             self._buffer.free()
             self._needs_free = False

Modified: pypy/dist/pypy/lib/_ctypes/primitive.py
==============================================================================
--- pypy/dist/pypy/lib/_ctypes/primitive.py	(original)
+++ pypy/dist/pypy/lib/_ctypes/primitive.py	Fri Feb 15 09:51:54 2008
@@ -219,7 +219,7 @@
     def __nonzero__(self):
         return self._buffer[0] not in (0, '\x00')
 
-    def __del__(self):
+    def delete(self):
         if self._needs_free:
             self._needs_free = False
             self._buffer.free()

Modified: pypy/dist/pypy/lib/_ctypes/structure.py
==============================================================================
--- pypy/dist/pypy/lib/_ctypes/structure.py	(original)
+++ pypy/dist/pypy/lib/_ctypes/structure.py	Fri Feb 15 09:51:54 2008
@@ -176,7 +176,7 @@
     def _get_buffer_for_param(self):
         return self._buffer.byptr()
 
-    def __del__(self):
+    def delete(self):
         if self._needs_free:
             self._buffer.free()
             self.__dict__['_buffer'] = None



More information about the Pypy-commit mailing list