SpamExperts / pyzor

Pyzor is a Python implementation of a spam-blocking networked system that use spam signatures to identify them.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pyzor script can’t run its own test?

FGasper opened this issue · comments

Version information

1.0.0

Steps to replicate

  1. Run the following script. (Note that $bad_encoding comes directly from tests/functional/test_digest.py in the pyzor repository.)
#!/usr/bin/env perl

use strict;
use warnings;
use autodie;

my $bad_encoding = <<"END";
From nobody Tue Apr  1 13:18:54 2014
Content-Type: multipart/related;
 boundary="===============0632694142025794937=="
MIME-Version: 1.0\x00\x00\x00

This is a multi-part message in MIME format.
--===============0632694142025794937==
Content-Type: text/plain; charset=ISO-8859-1\x00\x00\x00Content-Transfer-Encoding: quoted-printable

This is a test

--===============0632694142025794937\x00\x00\x00==
Content-Type: text/plain; charset=us-asciia
Content-Transfer-Encoding: quoted-printable

This is a test

--===============0632694142025794937==
END

pipe my $r, my $w;

syswrite $w, $bad_encoding;

open \*STDIN, '<&=', $r;
exec 'pyzor', 'digest';

Actual result

The script blows up with:

Traceback (most recent call last):
  File "/usr/bin/pyzor", line 5, in <module>
    pkg_resources.run_script('pyzor==1.0.0', 'pyzor')
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 540, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 1462, in run_script
    exec_(script_code, namespace, namespace)
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 41, in exec_
    exec("""exec code in globs, locs""")
  File "<string>", line 1, in <module>
  File "/usr/lib/python2.7/site-packages/pyzor-1.0.0-py2.7.egg/EGG-INFO/scripts/pyzor", line 408, in <module>

  File "/usr/lib/python2.7/site-packages/pyzor-1.0.0-py2.7.egg/EGG-INFO/scripts/pyzor", line 152, in main

  File "/usr/lib/python2.7/site-packages/pyzor-1.0.0-py2.7.egg/EGG-INFO/scripts/pyzor", line 309, in digest

  File "/usr/lib/python2.7/site-packages/pyzor-1.0.0-py2.7.egg/EGG-INFO/scripts/pyzor", line 175, in _get_input_msg

  File "build/bdist.linux-x86_64/egg/pyzor/digest.py", line 82, in __init__
  File "build/bdist.linux-x86_64/egg/pyzor/digest.py", line 160, in digest_payloads
TypeError: decode() argument 1 must be string without null bytes, not str

Expected result

It should presumably print 2b4dbf2fb521edd21d997f3f04b1c7155ba91fff plus a newline STDOUT, as the test expects.

From what I see this was fixed in #40 - changeset ed3a551