[pypy-svn] r34604 - pypy/dist/pypy/rpython/lltypesystem

mwh at codespeak.net mwh at codespeak.net
Tue Nov 14 17:43:59 CET 2006


Author: mwh
Date: Tue Nov 14 17:43:56 2006
New Revision: 34604

Modified:
   pypy/dist/pypy/rpython/lltypesystem/rclass.py
   pypy/dist/pypy/rpython/lltypesystem/rstr.py
Log:
don't crash when asked to print a NULL instance, say "NULL" instead.


Modified: pypy/dist/pypy/rpython/lltypesystem/rclass.py
==============================================================================
--- pypy/dist/pypy/rpython/lltypesystem/rclass.py	(original)
+++ pypy/dist/pypy/rpython/lltypesystem/rclass.py	Tue Nov 14 17:43:56 2006
@@ -569,8 +569,10 @@
         return hop.genop('ptr_nonzero', [vinst], resulttype=Bool)
 
     def ll_str(self, i): # doesn't work for non-gc classes!
-        instance = cast_pointer(OBJECTPTR, i)
         from pypy.rpython.lltypesystem import rstr
+        if not i:
+            return rstr.null_str
+        instance = cast_pointer(OBJECTPTR, i)
         nameLen = len(instance.typeptr.name)
         nameString = rstr.mallocstr(nameLen-1)
         i = 0

Modified: pypy/dist/pypy/rpython/lltypesystem/rstr.py
==============================================================================
--- pypy/dist/pypy/rpython/lltypesystem/rstr.py	(original)
+++ pypy/dist/pypy/rpython/lltypesystem/rstr.py	Tue Nov 14 17:43:56 2006
@@ -767,6 +767,8 @@
 instance_str_prefix = string_repr.convert_const("<")
 instance_str_suffix = string_repr.convert_const(" object>")
 
+null_str = string_repr.convert_const("NULL")
+
 unboxed_instance_str_prefix = string_repr.convert_const("<unboxed ")
 unboxed_instance_str_suffix = string_repr.convert_const(">")
 



More information about the Pypy-commit mailing list