[pypy-svn] r76832 - in pypy/trunk/pypy: module/cpyext rpython/lltypesystem

afa at codespeak.net afa at codespeak.net
Thu Sep 2 13:14:01 CEST 2010


Author: afa
Date: Thu Sep  2 13:13:58 2010
New Revision: 76832

Modified:
   pypy/trunk/pypy/module/cpyext/api.py
   pypy/trunk/pypy/rpython/lltypesystem/lltype.py
Log:
cpyext needs a *copy* of rffi.CCHARP which is distinct, but equal to rffi.CCHARP.


Modified: pypy/trunk/pypy/module/cpyext/api.py
==============================================================================
--- pypy/trunk/pypy/module/cpyext/api.py	(original)
+++ pypy/trunk/pypy/module/cpyext/api.py	Thu Sep  2 13:13:58 2010
@@ -62,11 +62,15 @@
 
 VA_LIST_P = rffi.VOIDP # rffi.COpaquePtr('va_list')
 CONST_STRING = lltype.Ptr(lltype.Array(lltype.Char,
-                                       hints={'nolength': True}))
+                                       hints={'nolength': True}),
+                          use_cache=False)
 CONST_WSTRING = lltype.Ptr(lltype.Array(lltype.UniChar,
-                                        hints={'nolength': True}))
+                                        hints={'nolength': True}),
+                           use_cache=False)
 assert CONST_STRING is not rffi.CCHARP
+assert CONST_STRING == rffi.CCHARP
 assert CONST_WSTRING is not rffi.CWCHARP
+assert CONST_WSTRING == rffi.CWCHARP
 
 # FILE* interface
 FILEP = rffi.COpaquePtr('FILE')

Modified: pypy/trunk/pypy/rpython/lltypesystem/lltype.py
==============================================================================
--- pypy/trunk/pypy/rpython/lltypesystem/lltype.py	(original)
+++ pypy/trunk/pypy/rpython/lltypesystem/lltype.py	Thu Sep  2 13:13:58 2010
@@ -624,16 +624,19 @@
     __name__ = property(lambda self: '%sPtr' % self.TO.__name__)
 
     _cache = weakref.WeakKeyDictionary()  # cache the Ptrs
-    def __new__(cls, TO):
-        try:
-            obj = Ptr._cache[TO]
-        except KeyError:
-            obj = Ptr._cache[TO] = LowLevelType.__new__(cls)
-        except TypeError:
+    def __new__(cls, TO, use_cache=True):
+        if not use_cache:
             obj = LowLevelType.__new__(cls)
+        else:
+            try:
+                obj = Ptr._cache[TO]
+            except KeyError:
+                obj = Ptr._cache[TO] = LowLevelType.__new__(cls)
+            except TypeError:
+                obj = LowLevelType.__new__(cls)
         return obj
 
-    def __init__(self, TO):
+    def __init__(self, TO, use_cache=True):
         if not isinstance(TO, ContainerType):
             raise TypeError, ("can only point to a Container type, "
                               "not to %s" % (TO,))



More information about the Pypy-commit mailing list