~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/xml_serializer.py

  • Committer: Marien Zwart
  • Date: 2006-09-22 00:51:36 UTC
  • mto: (2029.1.4 python25)
  • mto: This revision was merged to the branch mainline in revision 2030.
  • Revision ID: marienz@gentoo.org-20060922005136-6b5e0b856a4baff3
Handle the different exception (non-c)ElementTree raises.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
    from cElementTree import (ElementTree, SubElement, Element,
29
29
                              XMLTreeBuilder, fromstring, tostring)
30
30
    import elementtree
 
31
    ParseError = SyntaxError
31
32
except ImportError:
32
33
    mutter('WARNING: using slower ElementTree; consider installing cElementTree'
33
34
           " and make sure it's on your PYTHONPATH")
35
36
                                              Element, XMLTreeBuilder,
36
37
                                              fromstring, tostring)
37
38
    import util.elementtree as elementtree
 
39
    from xml.parsers.expat import ExpatError as ParseError
38
40
 
39
41
from bzrlib import errors
40
42
 
52
54
    def read_inventory_from_string(self, xml_string):
53
55
        try:
54
56
            return self._unpack_inventory(fromstring(xml_string))
55
 
        except SyntaxError, e:
 
57
        except ParseError, e:
56
58
            raise errors.UnexpectedInventoryFormat(e)
57
59
 
58
60
    def read_inventory(self, f):
59
61
        try:
60
62
            return self._unpack_inventory(self._read_element(f))
61
 
        except SyntaxError, e:
 
63
        except ParseError, e:
62
64
            raise errors.UnexpectedInventoryFormat(e)
63
65
 
64
66
    def write_revision(self, rev, f):