[XML-SIG] DOM memory problem

Andrew Clover and-xml at doxdesk.com
Sun Feb 1 07:43:42 EST 2004


Bruce Jewell <bruce.jewell at symmetron.com> wrote:

> My problem is that this threw an exception IOError:[Errno 12]Not
> enough space.

You're using Windows, right? sys.stdin behaves oddly under Python for
Windows, it's not a PyXML-specific problem. Was mentioned here with no
obvious solution:

  http://groups.google.de/groups?threadm=mailman.1020460208.1269.python-list%40python.org&rnum=1

(On Win 9x, stdout may be affected too, judging by this:)

  http://mail.python.org/pipermail/python-bugs-list/2002-November/014356.html

PyXML is trying to read stdin to an arbitrarily-sized buffer. If the buffer
is larger than a certain critical size, Windows will give it an IOError.
This size is 0x6FFF on my Py2.3/WinXP setup, unless Python is run with the
-u switch in which case (for some reason) it is 0x4FFF. This may vary; 1.5.2
also seems to get stuck at 0x4FFFF.

Currently xml.sax.xmlreader is defaulting to 0x10000:

    def __init__(self, bufsize=2**16):

if this line (111) is changed to 0x4000 it seems to make the problems go
away.

It may be worth making this change to PyXML to avoid this problem cropping
up for Win users. But in the longer term think Python itself ought to
include a workaround (assuming it is indeed a bug in Microsoft's stdio
implementation).

-- 
Andrew Clover
mailto:and at doxdesk.com
http://www.doxdesk.com/



More information about the XML-SIG mailing list