Package: fbless
Version: 0.2.3-8
Severity: normal
Tags: patch

Dear maintainers,

fbless exits with exception "decoding str is not supported" on some books.
I guess the problem is related to strings/bytes conversion.

I fixed this issue with the patch on top of existing changes in package.
Please, consider applying it.

Thanks!

--- a/fbless_lib/hyphenation.py
+++ b/fbless_lib/hyphenation.py
@@ -70,8 +70,8 @@
 
         hyph_pats = {}
 
-        fd = open(dict_file)
-        encoding = fd.readline().strip()
+        fd = open(dict_file, "rb")
+        encoding = fd.readline().strip().decode("ascii")
 
         for l in fd.readlines():
             l = str(l, encoding).strip()
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/fbless_lib/main.py", line 915, in get
    line = par.lines[line_index]
           ~~~~~~~~~^^^^^^^^^^^^
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/fbless", line 23, in <module>
    MainWindow().main_loop()
    ~~~~~~~~~~^^
  File "/usr/lib/python3/dist-packages/fbless_lib/main.py", line 88, in __init__
    self.redraw_scr()
    ~~~~~~~~~~~~~~~^^
  File "/usr/lib/python3/dist-packages/fbless_lib/main.py", line 230, in 
redraw_scr
    s, type = self.content.get(_par_index, _line_index)
              ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/fbless_lib/main.py", line 919, in get
    return self.get(par_index, line_index)
           ~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/fbless_lib/main.py", line 913, in get
    self._split_par(par)
    ~~~~~~~~~~~~~~~^^^^^
  File "/usr/lib/python3/dist-packages/fbless_lib/main.py", line 1011, in 
_split_par
    par.split_string()
    ~~~~~~~~~~~~~~~~^^
  File "/usr/lib/python3/dist-packages/fbless_lib/paragraph.py", line 185, in 
split_string
    wl = hyph.hyphenate(word, self.lang)
  File "/usr/lib/python3/dist-packages/fbless_lib/hyphenation.py", line 128, in 
hyphenate
    for j in hyphenate_func(ww, lang):
             ~~~~~~~~~~~~~~^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/fbless_lib/hyphenation.py", line 169, in 
tex_hyphenate
    self.hyph_pats[lang] = self.read_patterns(lang)
                           ~~~~~~~~~~~~~~~~~~^^^^^^
  File "/usr/lib/python3/dist-packages/fbless_lib/hyphenation.py", line 77, in 
read_patterns
    l = str(l, encoding).strip()
        ~~~^^^^^^^^^^^^^
TypeError: decoding str is not supported

Reply via email to