pyClamd 0.1.1 doesn't work with Python 2.6

Bug #771955 reported by Brendan Long
12
This bug affects 1 person
Affects Status Importance Assigned to Milestone
pyclamd (Debian)
Fix Released
Unknown
pyclamd (Ubuntu)
Fix Released
Undecided
Unassigned
Lucid
Fix Released
Medium
Stefano Rivera

Bug Description

Binary package hint: python-pyclamd

The version of pyClamd included in Ubuntu 10.04 uses old-style Python exceptions (raise ExceptionType, string), but Python 2.6 won't allow that:

Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyclamd
>>> pyclamd.init_unix_socket("/var/run/clamav/clamd.ctl")
>>> pyclamd.scan_file("cats")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/pymodules/python2.6/pyclamd.py", line 286, in scan_file
    raise ScanError, virusname
TypeError: exceptions must be old-style classes or derived from BaseException, not str

It works fine in version 2.2 (latest). As it stands now, the module is completely unusable.

Revision history for this message
Stefano Rivera (stefanor) wrote :

This was fixed in 0.1.1-2, which is in maverick. I suppose it's probably worth preparing a fix for Lucid.

Would you prepare instructions on testing the bug? I.e. minimal instructions for triggering it, expected and unexpected (broken) responses.

https://wiki.ubuntu.com/StableReleaseUpdates#Procedure

Changed in pyclamd (Ubuntu):
status: New → Fix Released
Revision history for this message
Brendan Long (korin43) wrote :

To test, install python-pyclamd and clamav-daemon:

$ sudo aptitude install python-pyclamd clamav-daemon

Update the virus definition database (to make sure you have one):

$ sudo -u clamav freshclam

Then do anything that would make it raise an exception:

$ python
>>> import pyclamd
>>> pyclamd.init_unix_socket("/var/run/clamav/clamd.ctl")
>>> pyclamd.scan_file("file_that_doesnt_exist")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/pymodules/python2.6/pyclamd.py", line 350, in scan_file
    raise ScanError(reason)
pyclamd.ScanError: lstat() failed: No such file or directory.

The above output is correct (raising a ScanError). On 1.1, you get this instead:

>>> import pyclamd
>>> pyclamd.init_unix_socket("/var/run/clamav/clamd.ctl")
>>> pyclamd.scan_file("file_that_doesnt_exist")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/pymodules/python2.6/pyclamd.py", line 286, in scan_file
    raise ScanError, virusname
TypeError: exceptions must be old-style classes or derived from BaseException, not str

Revision history for this message
Stefano Rivera (stefanor) wrote :

Hi, sorry I haven't got to this in a couple of weeks, it's been an open tab forever.
I'll try and get to it soon, but this is also an issue that is easy to fix and suitable
for newcomers in Ubuntu development.

If anyone needs any help with fixing it, talk to me (https://launchpad.net/~stefanor) about it.

tags: added: bitesize
Revision history for this message
Stefano Rivera (stefanor) wrote :

Right, got to it. Uploaded to lucid-proposed, pending SRU team review.

Changed in pyclamd (Ubuntu Lucid):
assignee: nobody → Stefano Rivera (stefanor)
importance: Undecided → Medium
status: New → Fix Committed
Revision history for this message
Stefano Rivera (stefanor) wrote :
Revision history for this message
Martin Pitt (pitti) wrote : Please test proposed package

Accepted pyclamd into lucid-proposed, the package will build now and be available in a few hours. Please test and give feedback here. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Thank you in advance!

tags: added: verification-needed
Revision history for this message
Brendan Long (korin43) wrote :

Looks good to me. The script I posted above, and my actual program both work now. Thanks for the help.

Revision history for this message
Jean-Baptiste Lallement (jibel) wrote :

Thanks for testing. Marking as verification-done

tags: added: verification-done
removed: verification-needed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package pyclamd - 0.1.1-1ubuntu0.1

---------------
pyclamd (0.1.1-1ubuntu0.1) lucid-proposed; urgency=low

  * Change exceptions from strings to classes, for python 2.6 compatibility.
    Patch from 0.1.1-2. (LP: #771955)
 -- Stefano Rivera <email address hidden> Fri, 20 May 2011 18:45:41 +0200

Changed in pyclamd (Ubuntu Lucid):
status: Fix Committed → Fix Released
Changed in pyclamd (Debian):
status: Unknown → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.