Dear maintainer,
Related to this one:
* [0e1593] Include patch from upstream (Closes: 923077
<https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=923077>)
I forgot to report above that this patch on its own isn't enough, as it
will throw the following error:
internal error, python traceback seen in response: Traceback (most
recent call last):
File "/usr/bin/pyzor", line 411, in <module>
main()
File "/usr/bin/pyzor", line 152, in main
if not dispatch(client, servers, config):
File "/usr/bin/pyzor", line 240, in check
for digested in get_input_handler(style):
File "/usr/bin/pyzor", line 177, in _get_input_msg
msg = email.message_from_bytes(get_binary_stdin().read())
NameError: name 'get_binary_stdin' is not defined at
/usr/share/perl5/Mail/SpamAssassin/Plugin/Pyzor.pm line 308.
I attached an additional patch (extracted from upstream code) that I
applied locally to fully fix this.
Best regards,
Timo
--- pyzor 2021-01-10 19:21:51.000000000 +0100
+++ pyzor.patched 2021-01-13 07:52:27.754993225 +0100
@@ -179,9 +179,31 @@
yield digested
+def _is_binary_reader(stream, default=False):
+ try:
+ return isinstance(stream.read(0), bytes)
+ except Exception:
+ return default
+
+
+def get_binary_stdin():
+ # sys.stdin might or might not be binary in some extra cases. By
+ # default it's obviously non binary which is the core of the
+ # problem but the docs recommend changing it to binary for such
+ # cases so we need to deal with it.
+ is_binary = _is_binary_reader(sys.stdin, False)
+ if is_binary:
+ return sys.stdin
+ buf = getattr(sys.stdin, 'buffer', None)
+ if buf is not None and _is_binary_reader(buf, True):
+ return buf
+ raise RuntimeError('Did not manage to get binary stdin')
+
+
def _get_input_mbox(digester):
tfile = tempfile.NamedTemporaryFile()
- tfile.write(sys.stdin.read().encode("utf8"))
+ #tfile.write(sys.stdin.read().encode("utf8"))
+ tfile.write(get_binary_stdin().read())
tfile.seek(0)
mbox = mailbox.mbox(tfile.name)
for msg in mbox: