On Mar 9, 9:02 am, BigHand <hewei...@gmail.com> wrote: > On Mar 8, 9:49 pm, "Gabriel Genellina" <gagsl-...@yahoo.com.ar> wrote: > > > > > En Sat, 07 Mar 2009 21:18:22 -0200, BigHand <hewei...@gmail.com> escribió: > > > > On 3月7日, 下午11时21分, "Gabriel Genellina" <gagsl-...@yahoo.com.ar> > > > wrote: > > >> En Sat, 07 Mar 2009 11:46:08 -0200, BigHand <hewei...@gmail.com> > > >> escribió: > > > >> > I want the exception printted like this: > > >> > File "<pyshell#14>", line 2, in <module> "a()" > > >> > File "<pyshell#6>", line 2, in a "b()" > > >> > File "<pyshell#9>", line 2, in b "return tuple()[0]" > > > >> Put your code in a true module stored in a file, so the source lines > > >> can > > >> be retrieved. > > > I don't understand you.could you give me more details? > > > C:\TEMP>type tbtest.py > > import sys > > import traceback > > > def a(): b() > > > def b(): raise ValueError > > > print("\none\n") > > try: a() > > except: > > exc_typ, exc_val, exc_tb = sys.exc_info() > > traceback.print_tb(exc_tb) > > > print("\ntwo\n") > > try: a() > > except: > > exc_typ, exc_val, exc_tb = sys.exc_info() > > traceback.print_tb(exc_tb) > > > print("\nthree\n") > > a() > > > C:\TEMP>python30 tbtest.py > > > one > > > File "tbtest.py", line 9, in <module> > > try: a() > > File "tbtest.py", line 4, in a > > def a(): b() > > File "tbtest.py", line 6, in b > > def b(): raise ValueError > > > two > > > File "tbtest.py", line 15, in <module> > > try: a() > > File "tbtest.py", line 4, in a > > def a(): b() > > File "tbtest.py", line 6, in b > > def b(): raise ValueError > > > three > > > Traceback (most recent call last): > > File "tbtest.py", line 21, in <module> > > a() > > File "tbtest.py", line 4, in a > > def a(): b() > > File "tbtest.py", line 6, in b > > def b(): raise ValueError > > ValueError > > > C:\TEMP> > > > -- > > Gabriel Genellina > > hello.Gabriel, > thanks very much! > > My another issue is that, I have an embedded python3.0 in my MFC app, > use the PyRun_File to execute the Py script file, and call the python > function traceback.print_tb to print the traceback info, > > but I can't get souce showed in the traceback.
solve it. I need to "import traceback" first in the script file. or I can't get the source retrieved later. -- http://mail.python.org/mailman/listinfo/python-list