TypeError: catching classes that do not inherit from BaseException is not allowed
写了一个demo异常类,没有继承BaseException类,提示报如下错误,很明显只要继承一下BaseException就可以了。
TypeError: catching classes that do not inherit from BaseException is not allowed 捕获到一个没有继承BaseException的异常类(这是不被允许的)。
Exception ignored in: <generator object demo_exc_handling at 0x000001D06C66E200>
Traceback (most recent call last):File "a5_3_coroutine_exception.py", line 10, in demo_exc_handling
TypeError: catching classes that do not inherit from BaseException is not allowed
class DemoException(): # DemoException(BaseException) 为正确写法"""demo异常类型"""passdef demo_exc_handling():print('-> coroutine started')while True:try:var = yieldexcept DemoException as e:print('*** DemoException handled. Continuing...')else:print('-> coroutine received: {!r}'.format(var))# raise RuntimeError('This line should never run.')cor_exc = demo_exc_handling()
cor_exc.send(None)
cor_exc.send(1)
TypeError: catching classes that do not inherit from BaseException is not allowed相关推荐
- 处理TypeError: A Message class can only inherit from Message
spyder中将 preferences -> python interpreter中的User Module Reloader关掉(如下图中设置),然后restart kernel
- From C++ to Objective-C
Contents(目录) Table of contents (章节目录) Introduction (导言) 1 Objective-C and Cocoa 1.1 A short history ...
- idea搭建javaweb项目 Artifacts生成
菜单:File - > Project Structure 图1 图2:静态资源文件 图3:java文件编译到WEB-INF/classes 图4:Inherit project compile ...
- 浅谈python MRO与Mixin模式
MRO(Method Resolution Order) In object-oriented programming languages with multiple inheritance, the ...
- Centos7 下cobbler安装及配置
1.背景介绍 作为运维,在公司经常遇到一些机械性重复工作要做,例如:为新机器装系统,一台两台机器装系统,可以用光盘.U盘等介质安装,1小时也完成了,但是如果有成百台的服务器还要用光盘.U盘去安装,就显 ...
- java需要记住什么英文_JAVA英语面试题(苦涩的记忆)
JAVA英语面试题(苦涩的记忆) (2010-01-30 14:59:02) 标签: 杂谈 java 英语面试题 2008-11-13 11:051.Tell me a little about yo ...
- Symbian 开发知识
找资料的时候发现这个不错就转过来啦 Symbian 开发知识,琐碎篇 General Hints / 一般提示 学习S2,我的方法无非是: ·每天coding,多少小时你自己掌握,看你有多少时间了. ...
- wine安装迅雷、qq2009
一.wine1.2终于出啦.虽然只是rc1.但是已经几近完美支持中文而且QQ不会突然崩溃. 单文件版的Q2009貌似就是TM版的.还不支持显示 用户是否是用手机登录的.而且分组顺序经常混乱.如今终于可 ...
- Win7系统安装tensorflow2.1.0报错解决方案
问题一: Could not find the DLL(s) 'msvcp140_1.dll'.TensorFlow requires that these DLLs be installed in ...
最新文章
- 基于蔡氏混沌电路进行非线性共振探究
- ExtJs与WCF交互:生成树
- 详解java集合之LinkedList——底层实现是头尾、双向节点,尽情地问我有没有看过集合源码吧!
- vb.net2019-多线程并行计算(3)
- [leetcode] 21.合并两个有序链表
- .NET6又出新版本,新增这几个大杀器!
- Mybatis多条件直接查询
- hystrix 源码 线程池隔离_Hystrix源码学习--线程池隔离
- FreeSql (三十四)CodeFirst 迁移说明
- 算法:Three sum求三个数之和
- 遗传算法python实现求最大值_python 遗传算法求函数极值的实现代码
- pdf转word乱码怎么办,可能是你没用对工具
- mysql cbrt函数_ES6 数值的扩展
- c语言洗牌发牌结构体,C语言实现洗牌发牌小程序
- CPU与CPU散热器 杂项
- 有感于新闻联播对威客(witkey)的报道
- FileMerge代码对比工具的简单使用
- Markus Persson:Minecraft 游戏背后的奇才
- 智卡调度APP的隐私声明
- ProtoPie vs. Axure:哪个最适合制作原型?
热门文章
- Genymotion Booting 安卓虚拟机 一直加载问题
- [Alg]排序算法之归并排序
- 离线强化学习(Offline RL)系列3: (算法篇)策略约束 - BRAC算法原理详解与实现(经验篇)
- LAYUI 表格 嵌套JSON不能显示的解决方法
- 团队作业—beta冲刺
- Android UI 模板
- 网工知识角-思科华为的网络工程师常用工具盘点
- 射频(RF)基本理论:定义、特性、调制、扩频
- HTML5期末大作业:个人空间相册网页设计 (6页) HTML+CSS+JavaScript
- pip安装tensorflow报错:could not find a version that satisfies the requirement grpcio=1.8.6