From 0d4b57722a15876442821c55501e6fa37c5fb885 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 8 Sep 2023 14:41:42 +0530 Subject: [PATCH] Fix #2034900 [Editor - Report: UnboundLocalError: local variable 'raw' referenced before assignment](https://bugs.launchpad.net/calibre/+bug/2034900) --- src/calibre/gui2/tweak_book/editor/text.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calibre/gui2/tweak_book/editor/text.py b/src/calibre/gui2/tweak_book/editor/text.py index d8439319fb..c32a76b632 100644 --- a/src/calibre/gui2/tweak_book/editor/text.py +++ b/src/calibre/gui2/tweak_book/editor/text.py @@ -503,13 +503,13 @@ class TextEdit(PlainTextEdit): if wrap and not complete: pos = QTextCursor.MoveOperation.End if reverse else QTextCursor.MoveOperation.Start c.movePosition(pos, QTextCursor.MoveMode.KeepAnchor) + raw = str(c.selectedText()).replace(PARAGRAPH_SEPARATOR, '\n').rstrip('\0') if hasattr(self.smarts, 'find_text'): self.highlighter.join() found, start, end = self.smarts.find_text(pat, c, reverse) if not found: return False else: - raw = str(c.selectedText()).replace(PARAGRAPH_SEPARATOR, '\n').rstrip('\0') m = pat.search(raw) if m is None: return False