Any way to get current file position in xml.parsers.expat?

C. Laurence Gonsalves clgonsal at keeshah.penguinpowered.com
Fri Jul 13 18:22:51 CEST 2001


On Fri, 13 Jul 2001 07:30:52 GMT, Van Gale <cgale1 at _remove_home.com> wrote:
>
>I'm pretty sure ErrorColumnNumber, ErrorLineNumber, and ErrorByteIndex
>are updated even when there is no error.

You're right, they do seem to get updated continuously. I didn't even
try checking this because the documentation explicitly says these values
won't be valid unless the parser raises an xml.parsers.expat.ExpatError
exception.

ie, http://python.org/doc/current/lib/xmlparser-objects.html says:

  The following attributes contain values relating to the most recent
  error encountered by an xmlparser object, and will only have correct
  values once a call to Parse() or ParseFile() has raised a
  xml.parsers.expat.ExpatError exception.

  ErrorByteIndex
    Byte index at which an error occurred.

  ...

  ErrorColumnNumber
    Column number at which an error occurred.

  ErrorLineNumber
    Line number at which an error occurred.

So is this an error in the documentation, or is the fact that these
values are continuousy updated merely a "quirk" in the current behaviour
that I shouldn't rely on because it may change at some point in the
future?

I'd be much happier if the docs didn't say that I can't do what I want
to do...

-- 
  C. Laurence Gonsalves                "Any sufficiently advanced
  clgonsal at kami.com                     technology is indistinguishable
  http://cryogen.com/clgonsal/          from magic." -- Arthur C. Clarke



More information about the Python-list mailing list