Package: python-lxml
Severity: serious
Version: 2.1.1-1

When the python-stats package is installed, attempting to use
lxml.etree results in an AttributeError being thrown:

ng:~# python -c 'import lxml.etree'
ng:~# apt-get install -qq python-stats
Selecting previously deselected package python-stats.
(Reading database ... 341464 files and directories currently installed.)
Unpacking python-stats (from .../python-stats_0.6-7_all.deb) ...
Setting up python-stats (0.6-7) ...
ng:~# python -c 'import lxml.etree'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "lxml.etree.pyx", line 40, in lxml.etree (src/lxml/lxml.etree.c:119415)
AttributeError: 'module' object has no attribute 'BytesIO'
ng:~# apt-get remove -qq python-stats
(Reading database ... 341473 files and directories currently installed.)
Removing python-stats ...
ng:~# python -c 'import lxml.etree'
ng:~# 

Lines 39-42 in lxml.etree.pyx look like this:

try:
    from io import BytesIO, StringIO
except ImportError:
    from StringIO import StringIO, StringIO as BytesIO

When python-stats is not installed, the 'io' module does not exist, so
line 40 throws an ImportError which is caught, and all is good. When
python-stats is installed, it installs `io.py', which seems unrelated to
this, and doesn't define BytesIO. Normally this would generate an
ImportError as well, but the C code generated from the .pyx tries to get
BytesIO as an attribute of io, which throws an AttributeError, which
goes uncaught and propagates up to the caller.

I'm not sure if this is a bug in python-lxml, python-stats, or whatever
generates the C from the pyx, but I'm filing this for python-lxml since
I know how to fix it there. Attached is a patch to the pyx which would
fix this issue when the C code is regenerated. I don't know how to
regenerate it (pyrex doesn't seem to like the pyx files, and I don't
know what else to try...), so the C is unpatched. Not sure if this is
the "correct" way to fix it, but it should work when the C is
regenerated.

Wasn't sure of the severity on this... an unrelated package installed
causes a rather large portion of this package to be unusable, and
anything that depends on it is thus unusable (I discovered this because
bcfg2 stopped working). Seems like it might be RC, though I'm unsure (it
seems like not Conflict'ing with python-stats could be a policy
violation when the package largely doesn't work when python-stats is
installed), but marking as serious just in case.

-- 
Andrew Deason
[EMAIL PROTECTED]
--- lxml-2.1.1/src/lxml/lxml.etree.pyx	2008-08-31 16:15:03.000000000 -0500
+++ lxml-2.1.1/src/lxml/lxml.etree.pyx	2008-08-31 16:16:30.000000000 -0500
@@ -38,7 +38,7 @@
 cdef object BytesIO, StringIO
 try:
     from io import BytesIO, StringIO
-except ImportError:
+except (ImportError, AttributeError):
     from StringIO import StringIO, StringIO as BytesIO
 
 cdef object _elementpath

Reply via email to