功能def _copying(self): result = self.result.toPlainText().strip().split('\n') to_copy = '\n'.join(result) pyperclip.copy(to_copy)在MainWindow()我PyQt5項目提出了在contextlib.py異常“的StopIteration” _GeneratorContextManager(),line 119 'next(self.gen)'。 result是一個ui.TextEdit對象。你能告訴我這是什么意思嗎?谷歌說我應(yīng)該把我的 func 包裝成 with-construction,但我真的不明白如何,也不確定這是個好主意。調(diào)試器說:__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控制臺什么也沒說。但該項目正在崩潰。
1 回答

慕碼人2483693
TA貢獻(xiàn)1860條經(jīng)驗 獲得超9個贊
StopIteration 是完全正常和預(yù)期的。這是正常運行的一部分contextlib.contextmanager
。應(yīng)該發(fā)生的,它被抓住并立即處理;如果它沒有發(fā)生,那就有問題了。
我不知道你是如何看到這個異常的,考慮到它永遠(yuǎn)不會逃脫contextlib
內(nèi)部結(jié)構(gòu),但是如果你將代碼的問題歸咎于它,那你就錯了事物。
添加回答
舉報
0/150
提交
取消