我有一個非常簡單的Python腳本:不明原因的段錯誤在Python
import Skype4Py
from random import randint
from time import strftime, sleep
from os import system
interval = 5
def pickStatus():
try:
handler = open("lines.txt", "r")
lines = handler.read().split("\n")
handler.close()
rand = randint(0, len(lines))
line = lines[rand]
print strftime("%Y-%m-%d %I:%M %p [" + str(rand) + "] ") + line
system('notify-send "New status" "' + line + '"')
skype.CurrentUserProfile.MoodText = line
sleep(interval * 60)
pickStatus()
except KeyboardInterrupt:
pass
if __name__ == '__main__':
skype = Skype4Py.Skype()
skype.Attach()
pickStatus()
當我運行它,我有時得到此:
~$ python RandomStatus.py
Segmentation fault
~$
其他時間,不過,劇本運行得很好。我所有的其他Python腳本也能正常工作。這個錯誤並沒有給我足夠的上下文,甚至不知道在哪裏尋找。有任何想法嗎?即使只是獲得一些實際的調試信息的方式,將不勝感激。
你確定它是Python的segfaulting,而不是你正在調用的程序'notify-send'嗎?你有沒有試過把'print'語句放在崩潰的地方? –
當然'系統'導致一個子過程。是不是不可能seg段父母? –
它看起來像是在skype.Attach()後發生。無論從哪裏來,我都會把它吐出一次:http://pastebin.com/EHJez3Zm –