[pypy-svn] r79528 - pypy/branch/fast-forward/lib_pypy/_ctypes

afa at codespeak.net afa at codespeak.net
Thu Nov 25 19:49:41 CET 2010


Author: afa
Date: Thu Nov 25 19:49:37 2010
New Revision: 79528

Modified:
   pypy/branch/fast-forward/lib_pypy/_ctypes/basics.py
   pypy/branch/fast-forward/lib_pypy/_ctypes/primitive.py
Log:
Fix repr() for subclasses of simple types,
and a hack to make the tests pass: CArgObject looks more like the object itself.


Modified: pypy/branch/fast-forward/lib_pypy/_ctypes/basics.py
==============================================================================
--- pypy/branch/fast-forward/lib_pypy/_ctypes/basics.py	(original)
+++ pypy/branch/fast-forward/lib_pypy/_ctypes/basics.py	Thu Nov 25 19:49:37 2010
@@ -103,6 +103,9 @@
     def __repr__(self):
         return repr(self._obj)
 
+    def __eq__(self, other):
+        return self._obj == other
+
 class _CData(object):
     """ The most basic object for all ctypes types
     """

Modified: pypy/branch/fast-forward/lib_pypy/_ctypes/primitive.py
==============================================================================
--- pypy/branch/fast-forward/lib_pypy/_ctypes/primitive.py	(original)
+++ pypy/branch/fast-forward/lib_pypy/_ctypes/primitive.py	Thu Nov 25 19:49:37 2010
@@ -316,7 +316,11 @@
         return self.value
 
     def __repr__(self):
-        return "%s(%r)" % (type(self).__name__, self.value)
+        if type(self).__bases__[0] is _SimpleCData:
+            return "%s(%r)" % (type(self).__name__, self.value)
+        else:
+            return "<%s object at 0x%x>" % (type(self).__name__,
+                                            id(self))
 
     def __nonzero__(self):
         return self._buffer[0] not in (0, '\x00')



More information about the Pypy-commit mailing list