简体   繁体   中英

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

So this has confused me for too long today. I am tossing it up to you guys.

I am getting

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

even when I simply use raise alone or with Exception()

Here is the whole traceback incase it helps. I am flummoxed...

---------------------------------------------------------------------------
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

Ok I seem to have found that the problem is not in my own code per se. I had been running the script inside Ipython: hence the toplevel trace address.

I decided to run it from the terminal and the exception is raised as expected.

I answered this myself even though I still don't know why Ipython is causing this to happen because that seems like a separate question I should ask.

Hope this helps someone seeing this weird behavior though.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM