[pypy-svn] pypy default: That's the one place where using py.io.saferepr() is not a good idea.

arigo commits-noreply at bitbucket.org
Thu Feb 24 15:00:56 CET 2011


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r42255:17bd126d3fee
Date: 2011-02-24 15:00 +0100
http://bitbucket.org/pypy/pypy/changeset/17bd126d3fee/

Log:	That's the one place where using py.io.saferepr() is not a good
	idea. The result was: when translate.py fails, we have a huge amount
	of output, followed by an error message that hides in "..." the real
	error. Let's just keep the full error message.

diff --git a/pypy/translator/platform/test/test_platform.py b/pypy/translator/platform/test/test_platform.py
--- a/pypy/translator/platform/test/test_platform.py
+++ b/pypy/translator/platform/test/test_platform.py
@@ -6,12 +6,12 @@
 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
+    # compilation error output/stdout may be large, but we don't want
+    # repr to create a limited version
     c = CompilationError('', '*'*1000)
-    assert len(repr(c)) < 500
+    assert repr(c) == 'CompilationError(err="""\n\t%s""")' % ('*'*1000,)
     c = CompilationError('*'*1000, '')
-    assert len(repr(c)) < 500
+    assert repr(c) == 'CompilationError(out="""\n\t%s""")' % ('*'*1000,)
 
 class TestPlatform(object):
     platform = host

diff --git a/pypy/translator/platform/__init__.py b/pypy/translator/platform/__init__.py
--- a/pypy/translator/platform/__init__.py
+++ b/pypy/translator/platform/__init__.py
@@ -19,9 +19,11 @@
 
     def __repr__(self):
         if self.err:
-            return "<CompilationError err=%s>" % py.io.saferepr(self.err)
+            attr = 'err'
         else:
-            return "<CompilationError out=%s>" % py.io.saferepr(self.out)
+            attr = 'out'
+        text = getattr(self, attr).replace('\n', '\n\t')
+        return 'CompilationError(%s="""\n\t%s""")' % (attr, text)
 
     __str__ = __repr__
 


More information about the Pypy-commit mailing list