[Python-bugs-list] [ python-Bugs-633480 ] IOError w/ large string to CMD shell

noreply@sourceforge.net noreply@sourceforge.net
Mon, 04 Nov 2002 13:34:33 -0800


Bugs item #633480, was opened at 2002-11-04 16:06
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=633480&group_id=5470

Category: Windows
Group: Python 2.2.1
Status: Open
Resolution: None
>Priority: 4
Submitted By: Michael McCandless (mikemccand)
>Assigned to: Nobody/Anonymous (nobody)
Summary: IOError w/ large string to CMD shell

Initial Comment:

If I try to run this program with "python2.2.1 -u":

  # 61409 works!!
  print ' ' * 61410

(which tries to print a string of 61,410 space characters), 
I get this Traceback on Windows 2000 SP2:

  Traceback (most recent call last):
    File "write.py", line 4, in ?
      print ' ' * 61410
  IOError: [Errno 12] Not enough space

Without "-u", this runs fine, and if I change "print" 
to "import sys; sys.stdout.write" instead, it still fails.

I think this is happening in Objects/fileobject.c -- the 
calls to fwrite apparently don't write all bytes in win32 
when the number of bytes is large -- seems like it may 
be necessary to parcel the data up into smaller pieces 
or something?

NOTE: it's possible that the exact length of the string 
that fails may be larger on other OS's...

----------------------------------------------------------------------

>Comment By: Tim Peters (tim_one)
Date: 2002-11-04 16:34

Message:
Logged In: YES 
user_id=31435

Couldn't reproduce under Win98SE and 2.2.2 even 
boosting the size to a million.  It *may* have to do with 
console-size settings under cmd.exe.

Reduced the priority.  "So don't do that" comes to mind 
<wink>.  Seriously, if the platform C fwrite chokes, it's not 
Python's job to fix it -- it's Microsoft's.  The interpreter isn't 
dying here, it's raising a well-behaved exception, just 
passing on the error the platform fwrite() raised.  To me it's 
the same as the system malloc complaining that you don't 
have enough memory to satisfy a request:  you've 
exceeded a platform limitation.  If this is important to you, 
you can presumably fix it yourself by chunking up your 
writes in a loop.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=633480&group_id=5470