[intrepid] Exception importing etree module

Bug #308194 reported by Morten Kjeldgaard
22
This bug affects 2 people
Affects Status Importance Assigned to Milestone
lxml (Debian)
Fix Released
Unknown
lxml (Ubuntu)
Fix Released
Undecided
Unassigned
Intrepid
Fix Released
Undecided
Unassigned

Bug Description

Binary package hint: python-lxml

I get an exception when importing the etree module from lxml:

$ python
Python 2.5.2 (r252:60911, Oct 5 2008, 19:29:17)
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from lxml import etree
Traceback (most recent call last):
  File "<stdin>", 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'
>>>

Source package: python-lxml_2.1.1-1

LSB Version: core-2.0-amd64:core-2.0-noarch:core-3.0-amd64:core-3.0-noarch:core-3.1-amd64:core-3.1-noarch:core-3.2-amd64:core-3.2-noarch
Distributor ID: Ubuntu
Description: Ubuntu 8.10
Release: 8.10
Codename: intrepid

Revision history for this message
Morten Kjeldgaard (mok0) wrote :

The above does not happen in version 2.2.1-2.1 currently in Lenny.

I suggest that package be synced into intrepid-updates.

Revision history for this message
Martin Pitt (pitti) wrote :

I cannot reproduce this on i386 on either current jaunty or current intrepid.

We only backport minimal fixes, we don't sync new upstream versions to stable Ubuntu releases. So this needs to be debugged properly first, and a patch identified which fixes this.

2.3.1-1 is source-synced into jaunty, but unfortunately it doesn't build yet (waiting for cython, which is in universe).

Changed in lxml:
status: New → Incomplete
status: New → Incomplete
Morten Kjeldgaard (mok0)
Changed in lxml:
assignee: nobody → mok0
status: Incomplete → In Progress
Revision history for this message
Morten Kjeldgaard (mok0) wrote :

The error only appears when python-stats is also installed. I have checked that this regression is true on both intrepid amd64 and intrepid i386. Why that is so I have not investigated further.

The attached patch updates the current intrepid lxml package to incorporate the patch available from lxml_2.1.1-2. However, since the bug fix is in a *.pyx file, that file needs to be recompiled with cython, but the intrepid version of cython fails. I used a more recent cython version; all this is explained in debian/changelog.

After this fix, the problem in the current bug is gone in intrepid. Below is the lsdiff and statdiff of the attached patch.

lsdiff:
lxml-2.1.1/debian/control
lxml-2.1.1/debian/changelog
lxml-2.1.1/src/lxml/lxml.etree.c
lxml-2.1.1/src/lxml/lxml.etree.pyx

diffstat:
 lxml-2.1.1/debian/changelog | 27 +
 lxml-2.1.1/debian/control | 3
 src/lxml/lxml.etree.c | 1095 +++++++++++++++++++++-----------------------
 src/lxml/lxml.etree.pyx | 2
 4 files changed, 564 insertions(+), 563 deletions(-)

Changed in lxml:
status: In Progress → Confirmed
assignee: mok0 → nobody
Morten Kjeldgaard (mok0)
Changed in lxml:
status: Incomplete → Confirmed
Revision history for this message
Martin Pitt (pitti) wrote :

Hey Morten, hi Matthias,

first, I still confirm the problem in jaunty. The lxml package FTBFSes with

running build_ext
error: Cython does not appear to be installed on platform 'posix'
[22329 refs]
make: *** [dbg-build-python2.4] Fehler 1

the 2.5 build works, but the 2.4 build fails. Matthias, any idea why this works in Debian, but not Ubuntu?

Morten, I looked at your debdiff, and the changelog says that you modified debian/rules to call cython, etc. However, the debdiff only ships a modified lxml.etree.c and the .pyx change, no other code/logic changes. If your intention is to just ship a working lxml.etree.c, that's good enough for an SRU, but then the changelog should explain that. If your intention is to have the file actually be generated on build, then some bits are missing. Thanks for any insight, and sorry for the long delay over the Christmas/new year holidays!

Revision history for this message
Matthias Klose (doko) wrote :

fixed in 2.0.5-1 in jaunty

Changed in lxml:
status: Confirmed → Fix Released
Revision history for this message
Morten Kjeldgaard (mok0) wrote :

Martin,

You are right, the changelog mention of rebuilding with cython should be removed. My old brain refuses to answer the query of what I did, but it is related to the discussion described in Bug #308633.

Basically, I found out that it is not safe to run cython during build; you have to go with the "compiled" .c files provided by the developer. I must have reverted the change I did to the rules file in the intrepid version as well.

Anyway, I attach a debdiff with a revised changelog entry, just saying that the lxml_etree.pyx file was recompiled.

Revision history for this message
Martin Pitt (pitti) wrote :

Thanks, sponsored.

Changed in lxml:
status: Confirmed → In Progress
Revision history for this message
Martin Pitt (pitti) wrote :

Accepted into intrepid-proposed, please test and give feedback here. Please see https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Thank you in advance!

Changed in lxml:
status: In Progress → Fix Committed
Revision history for this message
Martin Pitt (pitti) wrote :

Confirming that with the intrepid-proposed package, importing etree now works well.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package lxml - 2.1.1-1ubuntu1

---------------
lxml (2.1.1-1ubuntu1) intrepid-proposed; urgency=low

  * python-lxml failed import of lxml etree module (LP: #308194).
    To fix this we use patches from Debian Lenny version 2.1.1-2.1.
  * src/lxml/lxml.etree.pyx: This is the site of the basic fix, modifying
    one line:
      -except ImportError:
      +except (ImportError, AttributeError):
    The change is performed in situ since the package does not employ a
    patch system. Since this is in a *.pyx source file, the change spawns
    changes in other files too:
  * We need to generate src/lxml/lxml.*.[ch] from the .pyx files, and
    this was done using the intrepid version of Cython (0.9.6.14-1)
  * Normal Ubuntu maintainer mangling.

 -- Morten Kjeldgaard <email address hidden> Tue, 16 Dec 2008 15:18:59 +0100

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

Duplicates of this bug

Other bug subscribers

Remote bug watches

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