Package: python3-wikitrans
Version: 1.3-2
Severity: grave
Control: affects -1 dico-module-mediawiki
Usertags: pca.it-communication

Hi there,

after the dicod's `load python`[1] and `M4 quoting`[2], querying the
WikiMedia databases gives no match and the following errors in `dicod`:
```
root@harlock:~# /usr/bin/dicod --stderr -f
dicod: Info: dicod (GNU dico) 2.11 started
dicod: Info: Client info: "GNU dico 2.11"
dicod: Info: Client info: "GNU dico 2.11"
dicod: Debug: 57843 exited successfully
dicod: Info: Client info: "GNU dico 2.11"
dicod: Error: Traceback (most recent call last):
dicod: Error:   File "/usr/share/dico/python/mediawiki.py", line 98, in 
define_word
dicod: Error:     wikiparser = TextWiktionaryMarkup (text=data)
dicod: Error:                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
dicod: Error:   File "/usr/lib/python3/dist-packages/wikitrans/wiki2text.py", 
line 278, in __init__
dicod: Error:     super(TextWikiMarkup, self).__init__(*args, **keywords)
dicod: Error:   File "/usr/lib/python3/dist-packages/wikitrans/wikimarkup.py", 
line 1028, in __init__
dicod: Error:     self.text = keywords[kw].decode('utf-8').split("\n")
dicod: Error:                 ^^^^^^^^^^^^^^^^^^^
dicod: Error: AttributeError: 'str' object has no attribute 'decode'. Did you 
mean: 'encode'?
dicod: Debug: 57846 exited successfully
dicod: Debug: 57847 exited successfully
^Cdicod: Info: dicod (GNU dico) 2.11 terminating
root@harlock:~# 
```

[1] <https://bugs.debian.org/1028487>
[2] <https://bugs.debian.org/1056351>

I am not a Python expert, the problem obviously disappears (and the
query succeeds) if I remove the conditional case at line 1027, which
seems bad to me since AFAIK only from Python3 `str` contains by
default UTF-8/Unicode characters[3] (and anyway user input could not
be in UTF-8):
```
            elif kw == 'text':
                if sys.version_info[0] > 2:
                    self.text = keywords[kw].decode('utf-8').split("\n")
                else:
                    self.text = keywords[kw].split("\n")
```

[3] <https://docs.python.org/3/howto/unicode.html>

Thx, bye,
Gismo / Luca

-- System Information:
Debian Release: 12.2
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable-security'), (500, 
'oldstable-updates'), (500, 'oldstable-security'), (500, 'oldoldstable'), (500, 
'stable'), (500, 'oldstable'), (100, 'bookworm-fasttrack'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 6.5.0-0.deb12.1-amd64 (SMP w/8 CPU threads; PREEMPT)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_US:en
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages python3-wikitrans depends on:
ii  python3  3.11.2-1+b1

python3-wikitrans recommends no packages.

python3-wikitrans suggests no packages.

-- no debconf information

Attachment: signature.asc
Description: PGP signature

Reply via email to