From pykde Sat Aug 26 11:17:27 2006 From: Phil Thompson Date: Sat, 26 Aug 2006 11:17:27 +0000 To: pykde Subject: Re: [PyKDE] [PyQt4] bug in pyuic.py Message-Id: <200608261217.27796.phil () riverbankcomputing ! co ! uk> X-MARC-Message: https://marc.info/?l=pykde&m=115659187012529 On Friday 25 August 2006 12:40 pm, Jürgen Urner wrote: > Hello all > > This is probabbly alread known, but anyway. > There is a bug in pyuic.py, at least in PyQt-4.0.1 as I have it on my > machine (win). > > > > def generateUi(uifname, pyfname, execute, indent): > if pyfname == "-": > pyfile = sys.stdout > else: > pyfile = file(pyfname, "w") > > uic.compileUi(uifname, pyfile, execute, indent) > return 0 > > > > > ## ...should make shure pyfile is closed if its not stdout > def generateUi(uifname, pyfname, execute, indent): > is_stdout = True > if pyfname == "-": > pyfile = sys.stdout > else: > pyfile = file(pyfname, "w") > is_stdout = False > > try: > uic.compileUi(uifname, pyfile, execute, indent) > finally: > if not is_stdout: > pyfile.close() > return 0 Python closes the file automatically when the file object is garbage collected. Phil _______________________________________________ PyKDE mailing list PyKDE@mats.imk.fraunhofer.de http://mats.imk.fraunhofer.de/mailman/listinfo/pykde