Python 异常 查看BaseException的继承关系

举报
千江有水千江月 发表于 2021/07/15 17:15:50 2021/07/15
【摘要】 环境信息ModelArtsNotebook - pytorch1.4-cuda10.1-cudnn7-ubuntu18.04JupyterLab - Notebook - Conda-python3  异常 查看BaseException的继承关系BaseException # 所有异常的基类BaseException# 查看直接父类BaseException.__bases__(obj...

环境信息

  • ModelArts
    • Notebook - pytorch1.4-cuda10.1-cudnn7-ubuntu18.04
      • JupyterLab - Notebook - Conda-python3

异常 查看BaseException的继承关系

BaseException  # 所有异常的基类

BaseException
# 查看直接父类
BaseException.__bases__

(object,)
BaseException.__subclasses__()


[Exception, GeneratorExit, SystemExit, KeyboardInterrupt]
# Exception 异常
# GeneratorExit 生成器异常
# SystemExit python解释器退出
# KeyboardInterrupt 键盘中断
Exception.__bases__, GeneratorExit.__bases__, SystemExit.__bases__, KeyboardInterrupt.__bases__

((BaseException,), (BaseException,), (BaseException,), (BaseException,))
GeneratorExit.__subclasses__(), SystemExit.__subclasses__(), KeyboardInterrupt.__subclasses__()

([], [], [])
Exception.__subclasses__()

[TypeError,
 StopAsyncIteration,
 StopIteration,
 ImportError,
 OSError,
 EOFError,
 RuntimeError,
 NameError,
 AttributeError,
 SyntaxError,
 LookupError,
 ValueError,
 AssertionError,
 ArithmeticError,
 SystemError,
 ReferenceError,
 MemoryError,
 BufferError,
 Warning,
 locale.Error,
 warnings._OptionError,
 runpy._Error,
 re.error,
 sre_parse.Verbose,
 subprocess.SubprocessError,
 tokenize.TokenError,
 tokenize.StopTokenizing,
 copy.Error,
 zlib.error,
 _lzma.LZMAError,
 shutil.RegistryError,
 inspect.EndOfBlock,
 traitlets.traitlets.TraitError,
 argparse.ArgumentError,
 argparse.ArgumentTypeError,
 traitlets.config.loader.ConfigError,
 traitlets.config.configurable.ConfigurableError,
 traitlets.config.application.ApplicationError,
 pydoc.ErrorDuringImport,
 bdb.BdbQuit,
 pdb.Restart,
 pexpect.exceptions.ExceptionPexpect,
 termios.error,
 struct.error,
 ptyprocess.util.PtyProcessError,
 IPython.utils.process.FindCmdError,
 IPython.utils.path.HomeDirError,
 IPython.core.profiledir.ProfileDirError,
 IPython.core.error.IPythonCoreError,
 IPython.core.error.InputRejected,
 getopt.GetoptError,
 binascii.Incomplete,
 pygments.util.OptionError,
 pygments.filters.ErrorToken,
 pickle._Stop,
 _pickle.PickleError,
 IPython.core.prefilter.PrefilterError,
 IPython.core.alias.AliasError,
 sqlite3.Error,
 sqlite3.Warning,
 IPython.core.interactiveshell.SpaceInInput,
 concurrent.futures._base.Error,
 socket._GiveupOnSendfile,
 asyncio.queues.QueueEmpty,
 asyncio.queues.QueueFull,
 asyncio.streams.LimitOverrunError,
 xml.dom.DOMException,
 prompt_toolkit.validation.ValidationError,
 prompt_toolkit.buffer.EditReadOnlyBuffer,
 prompt_toolkit.buffer._Retry,
 prompt_toolkit.layout.layout.InvalidLayoutError,
 prompt_toolkit.renderer.HeightIsUnknownError,
 _queue.Empty,
 queue.Full,
 parso.parser.ParserSyntaxError,
 parso.parser.InternalParseError,
 parso.python.diff._PositionUpdatingFinished,
 jedi.inference.helpers.SimpleGetItemNotFound,
 jedi.inference.utils.UncaughtAttributeError,
 jedi.inference.arguments.ParamIssue,
 jedi.api.exceptions._JediError,
 jedi.api.helpers.OnErrorLeaf,
 jedi.api.environment.InvalidPythonEnvironment,
 email.errors.MessageError,
 uu.Error,
 http.client.HTTPException,
 IPython.core.magics.code.InteractivelyDefined,
 IPython.terminal.embed.KillEmbedded,
 ctypes.ArgumentError,
 zmq.error.ZMQBaseError,
 jupyter_client.localinterfaces.NoIPAddresses,
 jupyter_client.channels.InvalidPortNumber,
 jupyter_client.multikernelmanager.DuplicateKernelError,
 tornado.util.TimeoutError,
 _curses.error,
 tornado.concurrent.ReturnValueIgnoredError,
 tornado.gen.KeyReuseError,
 tornado.gen.UnknownKeyError,
 tornado.gen.LeakedCallbackError,
 tornado.gen.BadYieldError,
 tornado.gen.ReturnValueIgnoredError,
 tornado.gen.Return,
 tornado.queues.QueueEmpty,
 tornado.queues.QueueFull]

help

help(BaseException)

Help on class BaseException in module builtins:

class BaseException(object)
 |  Common base class for all exceptions
 |  
 |  Methods defined here:

相关链接


备注

  1. 欢迎各位同学一起来交流学习心得^_^
  2. 在线课程、沙箱实验、认证、论坛和直播,其中包含了许多优质的内容,推荐了解与学习。
【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。