BaseException.message has been deprecated as of Python 2.6
ログにwarningが出てた。
BaseException.message has been deprecated as of Python 2.6
該当の箇所をみつけて再現させてみると、Exceptionをinheritしている独自のエラークラスのインスタンスに対して、messageを参照するとこのwarningが出るらしい。
メッセージの通りpython 2.6でwarningとなる。
2.7では問題ないようだった。
class MyException(Exception): pass try: raise MyException('this is error') except MyException as e: print "e:", e print "str(e):", str(e) print "e.args[0]:", e.args[0] print "e.message:", e.message # warning
warning無しでmessageを取得する方法はいくつかあるので、そちらを使うようにしてwarningを回避できる。
実行結果
e: this is error str(e): this is error e.args[0]: this is error e.message: this is error /path/to/scratch.py:10: DeprecationWarning: BaseException.message has been deprecated as of Python 2.6 print "e.message:", e.message # warning