python回溯异常未定义全局名称

时间:2015-03-18 20:44:21

标签: python

我有以下代码写入文件并打印任何异常。

目前,我得到一个例外,因为该文件夹不可用(这是有效的),但我得到了

error

 "global name 'exc_info' is not defined"...

代码

try:
        with open(tmp_file_upload + uploadfile.raw_filename,'w') as open_file:
                open_file.write(uploadfile.file.read())
    except Exception,err:
        import traceback
        exc_info = sys.exc_info()
        traceback.print_exception(*exc_info)
        print "File write failed"

完整追踪:

[Wed Mar 18 16:28:48 2015] [error] [client 10.172.16.81]   File "/web/docs/bottle.py", line 861, in _handle
[Wed Mar 18 16:28:48 2015] [error] [client 10.172.16.81]     return route.call(**args)
[Wed Mar 18 16:28:48 2015] [error] [client 10.172.16.81]   File "/web/docs/bottle.py", line 1725, in wrapper
[Wed Mar 18 16:28:48 2015] [error] [client 10.172.16.81]     rv = callback(*a, **ka)
[Wed Mar 18 16:28:48 2015] [error] [client 10.172.16.81]   File "/web/docs/GUI/PBottleApp.py", line 293, in datasets
[Wed Mar 18 16:28:48 2015] [error] [client 10.172.16.81]     exc_info = sys.exc_info()
[Wed Mar 18 16:28:48 2015] [error] [client 10.172.16.81] NameError: global name 'exc_info' is not defined

0 个答案:

没有答案