[pypy-svn] r74220 - in pypy/branch/py12/pypy/translator/platform: . test

hpk at codespeak.net hpk at codespeak.net
Thu Apr 29 14:20:51 CEST 2010


Author: hpk
Date: Thu Apr 29 14:20:50 2010
New Revision: 74220

Modified:
   pypy/branch/py12/pypy/translator/platform/__init__.py
   pypy/branch/py12/pypy/translator/platform/test/test_platform.py
Log:
use new py.io.saferepr facility and add a test where it is used


Modified: pypy/branch/py12/pypy/translator/platform/__init__.py
==============================================================================
--- pypy/branch/py12/pypy/translator/platform/__init__.py	(original)
+++ pypy/branch/py12/pypy/translator/platform/__init__.py	Thu Apr 29 14:20:50 2010
@@ -18,9 +18,9 @@
 
     def __repr__(self):
         if self.err:
-            return "<CompilationError err=%s>" % repr(self.err)
+            return "<CompilationError err=%s>" % py.io.saferepr(self.err)
         else:
-            return "<CompilationError out=%s>" % repr(self.out)
+            return "<CompilationError out=%s>" % py.io.saferepr(self.out)
 
     __str__ = __repr__
 

Modified: pypy/branch/py12/pypy/translator/platform/test/test_platform.py
==============================================================================
--- pypy/branch/py12/pypy/translator/platform/test/test_platform.py	(original)
+++ pypy/branch/py12/pypy/translator/platform/test/test_platform.py	Thu Apr 29 14:20:50 2010
@@ -5,6 +5,14 @@
 from pypy.translator.platform import host
 from pypy.translator.tool.cbuild import ExternalCompilationInfo
 
+def test_compilationerror_repr():
+    # compilation error output/stdout may be large, make sure
+    # repr creates a limited version
+    c = CompilationError('', '*'*1000)
+    assert len(repr(c)) < 500
+    c = CompilationError('*'*1000, '')
+    assert len(repr(c)) < 500
+
 class TestPlatform(object):
     platform = host
     strict_on_stderr = True



More information about the Pypy-commit mailing list