#35 py2exe -w crashes from to much stdout

closed-fixed
nobody
None
5
2004-02-10
2004-01-30
Ken Seehof
No

I build an non-console pygame application using py2exe
with the -w flag.

foo.exe stdout is redirected by py2exe.

The application spontaneously exits when the total
amount of print output exceeds about 4000 characters.

This is a nasty bug because it sometimes takes awhile
to output enough junk to crash, and time time of the
crash is difficult to correlate to anything. The
workaround is easy (just don't print - hey, there's no
console anyway), but it may take people some time to
find the problem in the first place.

Python 2.3.2

################
# setup.py
#
from distutils.core import setup
import glob
import py2exe

setup(name="foo",
scripts=["foo.py"], # with console window
)

################
# foo.py
#
import pygame
from pygame.locals import *
import random

r = random.randint

def main():
pygame.init()
screen = pygame.display.set_mode((800,600), 0, 8)

while not pygame.event.peek
((QUIT,KEYDOWN,MOUSEBUTTONDOWN)):
print 'x'*100 # "overflow" pseudo-stdout
color = (r(2,200),r(2,200),r(2,200))
pygame.draw.circle(screen, color, (200+r
(5,200),200+r(5,200)),
10+r(5,20))
pygame.display.flip()

main()

################

Discussion

  • Thomas Heller

    Thomas Heller - 2004-01-30

    Logged In: YES
    user_id=11105

    The 'correct' workaround, of course, is to redirect
    sys.stdout and sys.stderr:

    """
    class Null:
    ....def write(self, text): pass

    import sys
    sys.stdout = sys.stderr = Null()
    """

    In py2exe 0.5, something like this is done automatically (in
    py2exe\boot_common.py) for non-console exes. Output to
    sys.stdout is thrown away, output to sys.stderr goes into a
    log file, and at application exit a message box is displayed
    pointing to the logfile if there has been something written.

    Since boot_common.py is executed before the main script is
    started, all this can still be overrridden by the script
    itself. Does this make sense?

     
  • Thomas Heller

    Thomas Heller - 2004-01-30

    Logged In: YES
    user_id=11105

    BTW: IMO pythonw.exe has the same bug.

     
  • Thomas Heller

    Thomas Heller - 2004-02-10
    • status: open --> closed
     
  • Thomas Heller

    Thomas Heller - 2004-02-10
    • status: closed --> closed-fixed
     
  • Thomas Heller

    Thomas Heller - 2004-02-10

    Logged In: YES
    user_id=11105

    I would say this is fixed in py2exe 0.5.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks