Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/337.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python TypeError:异常必须是旧式类或从BaseException派生的,而不是NoneType_Python_Inheritance_Exception Handling_Ipython - Fatal编程技术网

Python TypeError:异常必须是旧式类或从BaseException派生的,而不是NoneType

Python TypeError:异常必须是旧式类或从BaseException派生的,而不是NoneType,python,inheritance,exception-handling,ipython,Python,Inheritance,Exception Handling,Ipython,这让我今天困惑太久了。我要把它交给你们 我越来越 TypeError: exceptions must be old-style classes or derived from BaseException, not NoneType 即使我只是单独使用raise或与Exception()一起使用 这是完整的回溯,以防有所帮助。我很困惑 --------------------------------------------------------------------------- Type

这让我今天困惑太久了。我要把它交给你们

我越来越

TypeError: exceptions must be old-style classes or derived from BaseException, not NoneType
即使我只是单独使用
raise
或与
Exception()一起使用

这是完整的回溯,以防有所帮助。我很困惑

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/home/gus/py274/lib/python2.7/site-packages/IPython/utils/py3compat.pyc in execfile(fname, *where)
    176             else:
    177                 filename = fname
--> 178             __builtin__.execfile(filename, *where)

/home/gus/Dropbox/repos/git/blacktie/src/blacktie/scripts/blacktie_pipeline.py in <module>()
    233 
    234 if __name__ == "__main__":
--> 235     main()

/home/gus/Dropbox/repos/git/blacktie/src/blacktie/scripts/blacktie_pipeline.py in main()
    203             # Prep cuffmerge call
    204             ##ipdb.set_trace()
--> 205             cuffmerge_call = CuffmergeCall(yargs,email_info,run_id,run_logs,conditions=experiment,mode=args.mode)
    206             cuffmerge_call.execute()
    207 

/home/gus/Dropbox/repos/git/blacktie/src/blacktie/utils/calls.pyc in __init__(self, yargs, email_info, run_id, run_logs, conditions, mode)
    627 
    628         self.prog_yargs = self.yargs.cuffmerge_options
--> 629         self.set_call_id()
    630         self.init_log_file()
    631         self.out_dir = self.get_out_dir()

/home/gus/Dropbox/repos/git/blacktie/src/blacktie/utils/calls.pyc in set_call_id(self)
    116             self.call_id = call_id
    117         else:
--> 118             raise Exception()
    119 
    120     def notify_start_of_call(self):

TypeError: exceptions must be old-style classes or derived from BaseException, not NoneType
---------------------------------------------------------------------------
TypeError回溯(最近一次调用上次)
/execfile(fname,*其中)中的home/gus/py274/lib/python2.7/site-packages/IPython/utils/py3compat.pyc
176.其他:
177 filename=fname
-->178 \uuuu内置\uuuuu.execfile(文件名,*其中)
/home/gus/Dropbox/repos/git/blacktie/src/blacktie/scripts/blacktie_pipeline.py in()
233
234如果名称=“\uuuuu main\uuuuuuuu”:
-->235 main()
/main()中的home/gus/Dropbox/repos/git/blacktie/src/blacktie/scripts/blacktie_pipeline.py
203#准备合并呼叫
204##ipdb.set#u trace()
-->205 cuffmerge\u call=CuffmergeCall(yargs,email\u info,run\u id,run\u日志,条件=实验,模式=args.mode)
206.合并u调用。执行()
207
/home/gus/Dropbox/repos/git/blacktie/src/blacktie/utils/calls.pyc in_uuuuuinit_uuuu(self、yargs、email_信息、运行id、运行日志、条件、模式)
627
628 self.prog_yargs=self.yargs.cuffmerge_选项
-->629 self.set_call_id()
630 self.init_log_文件()
631 self.out\u dir=self.get\u out\u dir()
/set\u call\u id(self)中的home/gus/Dropbox/repos/git/blacktie/src/blacktie/utils/calls.pyc
116 self.call\u id=call\u id
117其他:
-->118引发异常()
119
120 def通知启动呼叫(自我):
TypeError:异常必须是旧式类或从BaseException派生的,而不是NoneType

好的,我似乎发现问题不在我自己的代码本身。我一直在Ipython内部运行脚本:因此是顶级跟踪地址

我决定从终端上运行它,异常按预期引发

我自己回答了这个问题,尽管我仍然不知道为什么Ipython会导致这种情况发生,因为这似乎是我应该问的另一个问题


希望这有助于人们看到这种奇怪的行为。

这将有助于发布您的代码。您是否有可能将该范围中的名称
异常
重新定义为某个可调用并返回无?您可以在ipython(
%pdb
)中打开pdb,并查看它中断时异常是什么。不,我没有重新定义任何内容,我将异常更改为许多其他派生的“可提升项”。具体的类别无关紧要。问题似乎不在于我的代码。它来自于在ipython内部运行脚本。(见我的答案)谢谢。我和Ipython也有同样的问题。要不是你的回答,我要花很长时间才知道是伊皮顿。谢谢