[XML-SIG] Bug in exception handling?

Rob Hooft r.hooft@euromail.net
Thu, 24 Jun 1999 15:09:18 +0200 (MZT)


>>>>> "LMG" == Lars Marius Garshol <larsga@ifi.uio.no> writes:

 LMG> * Rob Hooft
 LMG> | 
 LMG> | What I (by accident) did find is that it has something to do with
 LMG> | Refcounting: The current code (drv_pyexpat) looks like:
 LMG> | 
 LMG> |         if not self.parser.Parse(fileobj.read(),1):
 LMG> |             self.__report_error()
 LMG> | 
 LMG> | If I replace that by 
 LMG> |         buf=fileobj.read()
 LMG> |         if not self.parser.Parse(buf,1):
 LMG> |             self.__report_error()
 LMG> | 
 LMG> | The exception does not dump core.

 LMG> Aha! Thanks for this observation. I've checked your patch into my
 LMG> driver source now, so it will be in the next release.

Sounds like a hack to me. Shouldn't it be solved by INCREF'ing the buffer
somewhere in the C code to pyexpat? e.g. where the exception code makes
reference to the buffer? I didn't look at the code myself, so I don't
know whether it is particularly difficult to find.

It would also be nice if the pyexpat parser would report the currect
line number for a problem even if the file is parsed in pieces (you
may have noticed that I was talking about 60MB files before, it is
not really nice to suck those into a single string).

Rob Hooft.

-- 
=====   R.Hooft@EuroMail.net   http://www.xs4all.nl/~hooft/rob/  =====
=====   R&D, Nonius BV, Delft  http://www.nonius.nl/             =====
===== PGPid 0xFA19277D ========================== Use Linux! =========