sys.excepthook close Pyscripter?

已查看 28 次
跳至第一个未读帖子

祝瑞仕

未读,
2016年1月15日 04:28:082016/1/15
收件人 PyScripter
The following code will exit Pyscripter completely. I'm not so if this is correct behavior of Pyscripter. Personally, I think it's abnormal.

def myhook(tp, val, tb):
    sys.exit()
sys.excepthook = myhook
raise

BBands

未读,
2016年1月15日 09:41:062016/1/15
收件人 PyScripter Group
Sometime asking a question is the best answer. What would you expect that snippet to do?

    John

祝瑞仕

未读,
2016年1月15日 09:48:132016/1/15
收件人 PyScripter
Did you run this script? The point is not about the snippet, but how come a script could affect an IDE like this.

BBands於 2016年1月15日星期五 UTC+8下午10時41分06秒寫道:

Harry

未读,
2016年1月15日 10:03:042016/1/15
收件人 PyScripter

I mean close Pyscripter.
BBands於 2016年1月15日星期五 UTC+8下午10時41分06秒寫道:

BBands

未读,
2016年1月15日 10:13:182016/1/15
收件人 PyScripter Group
It won't run here.

TypeError: exceptions must be old-style classes or derived from BaseException, not NoneType

Which Is why I asked you what you expected it to do.

      John

Harry

未读,
2016年1月15日 10:42:102016/1/15
收件人 PyScripter
I'm using Python 3.4.4.
raise will bring up RuntimeError. Since no one takes care of it, finally myhook will run and then do sys.exit() (although it's wired to call sys.exit())

BBands於 2016年1月15日星期五 UTC+8下午11時13分18秒寫道:

BBands

未读,
2016年1月15日 11:06:172016/1/15
收件人 PyScripter Group
Still can't duplicate. Obvious candidates, broken PyScripter / Python installs, 32/64 bit mismatch...

     John

Harry

未读,
2016年1月15日 12:52:232016/1/15
收件人 PyScripter
Don't jump to the conclusion so quickly. I guess you are using python 2. From the 
document https://goo.gl/t7D59U, raise doesn not have the same behaviour under 3.4. 
BBands於 2016年1月16日星期六 UTC+8上午12時06分17秒寫道:

BBands

未读,
2016年1月15日 13:29:012016/1/15
收件人 PyScripter Group
Cannot replicate crash behavior on either Python 2 or 3.

     John 
回复全部
回复作者
转发
0 个新帖子