Dmitry Kazakov added the comment:

I think the reason this patch hasn't been discussed well is that it only 
changes the behavior for traceback.*_tb functions that only deal with 
tracebacks. I commented on the review page that we don't have to change the 
behavior of traceback.*_stack functions to make it obvious. Let me show an 
example:

import sys

def a():
    b()

def b():
    c()

def c():
    d()

def d():
    def e():
        print_stack(limit=2) # Last 2 entries
        ''' Output:
            File "file", line 331, in d                                         
                                                                                
                                                              
              e()                                                               
                                                                                
                                                                          
            File "file", line 328, in e
              print_stack(limit=2) # Last 2 entries '''
        raise Exception
    e()
    
try:
    a()
except Exception:
    print_exc(limit=2) # 2 entries from the caller
    ''' Output:
        Traceback (most recent call last):
          File "file", line 336, in <module>
            a()
          File "file", line 318, in a
            b()
        Exception '''

If we decide to unify the behavior of *_tb and *_stack functions, the change 
will break some existing code, although the breakage will be purely cosmetic.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue22619>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to