Activity log for bug #1941992

Date Who What changed Old value New value Message
2021-08-29 12:57:45 Gregory Khvatsky bug added bug
2021-08-29 12:57:45 Gregory Khvatsky attachment added Patch that seems to fix this https://bugs.launchpad.net/bugs/1941992/+attachment/5521460/+files/fix_line_length.patch
2021-08-29 13:02:38 Gregory Khvatsky description When trying ebook-convert with TXT output and --max-line-length option set to more than 25, e.g. ebook-convert d_ch.fb2 text.txt --max-line-length 70 The command crashes with the following error: ..... Converting XHTML to TXT... Traceback (most recent call last): File "runpy.py", line 194, in _run_module_as_main File "runpy.py", line 87, in _run_code File "site.py", line 45, in <module> File "site.py", line 41, in main File "calibre/ebooks/conversion/cli.py", line 401, in main File "calibre/ebooks/conversion/plumber.py", line 1271, in run File "calibre/ebooks/conversion/plugins/txt_output.py", line 100, in convert File "calibre/ebooks/txt/txtml.py", line 65, in extract_content File "calibre/ebooks/txt/txtml.py", line 86, in mlize_spine File "calibre/ebooks/txt/txtml.py", line 160, in cleanup_text TypeError: slice indices must be integers or None or have an __index__ method This is most likely due to the fact that for some reason, in the function cleanup_text, the type of self.opts.max_line_length is float, which, when passed to line.rfind(...) on line 160, causes the error. This behavior of rfind can be reproduced by running something like "aaaa aaaa".rfind(" ", 0, 1.0) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: slice indices must be integers or None or have an __index__ method In a Python console. Included is a patch that fixes this by forcibly converting self.opts.max_line_length to an int, although I am not sure whether it broke something else or not. When trying ebook-convert (from calibre 5.26.0 on Linux) with TXT output and --max-line-length option set to more than 25, e.g. ebook-convert d_ch.fb2 text.txt --max-line-length 70 The command crashes with the following error: ..... Converting XHTML to TXT... Traceback (most recent call last):   File "runpy.py", line 194, in _run_module_as_main   File "runpy.py", line 87, in _run_code   File "site.py", line 45, in <module>   File "site.py", line 41, in main   File "calibre/ebooks/conversion/cli.py", line 401, in main   File "calibre/ebooks/conversion/plumber.py", line 1271, in run   File "calibre/ebooks/conversion/plugins/txt_output.py", line 100, in convert   File "calibre/ebooks/txt/txtml.py", line 65, in extract_content   File "calibre/ebooks/txt/txtml.py", line 86, in mlize_spine   File "calibre/ebooks/txt/txtml.py", line 160, in cleanup_text TypeError: slice indices must be integers or None or have an __index__ method This is most likely due to the fact that for some reason, in the function cleanup_text, the type of self.opts.max_line_length is float, which, when passed to line.rfind(...) on line 160, causes the error. This behavior of rfind can be reproduced by running something like "aaaa aaaa".rfind(" ", 0, 1.0) Traceback (most recent call last):   File "<stdin>", line 1, in <module> TypeError: slice indices must be integers or None or have an __index__ method In a Python console. Included is a patch that fixes this by forcibly converting self.opts.max_line_length to an int, although I am not sure whether it broke something else or not.
2021-08-29 13:39:14 Kovid Goyal calibre: status New Fix Released