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

fijal at codespeak.net fijal at codespeak.net
Fri Feb 15 13:37:43 CET 2008


Author: fijal
Date: Fri Feb 15 13:37:42 2008
New Revision: 51523

Modified:
   pypy/dist/pypy/lib/_ctypes/primitive.py
   pypy/dist/pypy/lib/_ctypes/structure.py
Log:
another keepalive


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 13:37:42 2008
@@ -73,6 +73,7 @@
                     if isinstance(value, unicode):
                         value = value.encode(ConvMode.encoding,
                                              ConvMode.errors)
+                    self._objects = value
                     array = _rawffi.Array('c')(len(value)+1, value)
                     value = array.buffer
                     # XXX free 'array' later
@@ -95,6 +96,7 @@
                     if isinstance(value, str):
                         value = value.decode(ConvMode.encoding,
                                              ConvMode.errors)
+                    self._objects = value
                     array = _rawffi.Array('u')(len(value)+1, value)
                     value = array.buffer
                     # XXX free 'array' later

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 13:37:42 2008
@@ -108,6 +108,7 @@
                 raise TypeError("Cannot instantiate structure, has no _fields_")
             self.__dict__['_buffer'] = self._ffistruct()
             self.__dict__['_needs_free'] = True
+            self.__dict__['_objects'] = {}
             if len(args) > len(self._names):
                 raise TypeError("too many arguments")
             for name, arg in zip(self._names, args):
@@ -117,7 +118,6 @@
                 self.__setattr__(name, arg)
             for name, arg in kwds.items():
                 self.__setattr__(name, arg)
-            self.__dict__['_objects'] = {}
         res.__init__ = __init__
 
 
@@ -165,8 +165,8 @@
         except KeyError:
             raise AttributeError(name)
         if getattr(value, '_objects', None):
-            self._objects[str(getattr(self.__class__, name).offset)] = \
-                                                      value._objects
+            key = str(getattr(self.__class__, name).offset)
+            self.__dict__['_objects'][key] = value._objects
         value = fieldtype._CData_input(value)
         self._buffer.__setattr__(name, value[0])
 



More information about the Pypy-commit mailing list