函数
def _copying(self):
result = self.result.toPlainText().strip().split('\n')
to_copy = '\n'.join(result)
pyperclip.copy(to_copy)在MainWindow() of my PyQt5项目中,contextlib.py _GeneratorContextManager(),line 119 'next(self.gen)'中会引发一个异常"StopIteration“。result是一个ui.TextEdit对象。你能告诉我这是什么意思吗?谷歌说,我应该把我的功能与-建设,但我不知道怎么做,也不确定这是一个好主意。
调试器说:
__exception__ = {tuple} <class 'tuple'>: (<class 'StopIteration'>, StopIteration(), <traceback object at 0x045DA918>)
0 = {type} <class 'StopIteration'>
args = {getset_descriptor} <attribute 'args' of 'BaseException' objects>
value = {member_descriptor} <member 'value' of 'StopIteration' objects>
1 = {StopIteration}
args = {tuple} <class 'tuple'>: ()
value = {NoneType} None
2 = {traceback} <traceback object at 0x045DA918>
tb_frame = {frame} __exit__ [contextlib.py:119] id:54111736
tb_lasti = {int} 16
tb_lineno = {int} 119
tb_next = {NoneType} None
__len__ = {int} 3控制台什么都没说。但这个项目正在崩溃。
发布于 2019-02-01 07:42:54
StopIteration是完全正常和预期的。这是contextlib.contextmanager正常运行的一部分。这是应该发生的,并立即被捕获和处理;如果不发生,就会有一个问题。
我不知道您是如何最终看到这个异常的,考虑到它是如何避免contextlib内部的,但是如果您将代码的问题归咎于它,那么您就错了。
https://stackoverflow.com/questions/54474393
复制相似问题