Author: Ronan Lamy <[email protected]>
Branch: py3.6
Changeset: r97954:7d23f033e2ba
Date: 2019-11-04 20:10 +0000
http://bitbucket.org/pypy/pypy/changeset/7d23f033e2ba/

Log:    Handle large sys.tracebacklimit correctly

diff --git a/pypy/module/sys/app.py b/pypy/module/sys/app.py
--- a/pypy/module/sys/app.py
+++ b/pypy/module/sys/app.py
@@ -31,6 +31,8 @@
             # one is counting from the top, the other from the bottom of the
             # stack. so reverse polarity here
             if limit > 0:
+                if limit > sys.maxsize:
+                    limit = sys.maxsize
                 print_exception(exctype, value, traceback, limit=-limit)
             else:
                 # the limit is 0 or negative. PyTraceBack_Print does not print
diff --git a/pypy/module/sys/test/test_sysmodule.py 
b/pypy/module/sys/test/test_sysmodule.py
--- a/pypy/module/sys/test/test_sysmodule.py
+++ b/pypy/module/sys/test/test_sysmodule.py
@@ -163,7 +163,7 @@
             # see comment in 'setup_after_space_initialization'
             untranslated_enc = {'win32': 'mbcs', 'darwin': 'utf-8'}.get(enc, 
'ascii')
             assert enc == untranslated_enc
-            
+
 
     def test_float_info(self):
         import sys
@@ -402,9 +402,9 @@
             raise ValueError(42)
 
         def get_error_with_tracebacklimit(limit):
-            import io
+            import _io
             sys.tracebacklimit = limit
-            sys.stderr = err = io.StringIO()
+            sys.stderr = err = _io.StringIO()
             try:
                 f1()
             except ValueError:
@@ -425,6 +425,12 @@
         assert "Traceback (most recent call last):" not in msg
         assert "ValueError" in msg
 
+        msg = get_error_with_tracebacklimit(1<<100)
+        assert "Traceback (most recent call last):" in msg
+        assert "f1" in msg
+        assert "f2" in msg
+        assert "f3" in msg
+
         sys.stderr = savestderr
         del sys.tracebacklimit
 
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to