From: Tim B. <tb...@bi...> - 2004-06-01 20:00:13
|
I've got a PythonCard app that I have been converting to win32 standalone using py2exe to distribute. I've been using the resulting .exe for a while with no problems, but recently I made a seemingly minor change to my app that causes the resulting windows .exe (without console) to crash, presumably somewhere on background init. My app uses several constants that are defined in a module, Constants.py, which contains simple assignment statements like "a=1", "b=a", and "c=a+b". Previously, at the top of my app, I was simply doing "from Constants import *". But I wanted to be able to empower the user to dynamically update the constants used in their app without having to update the entire distribution folder. So I made the following change: From: from Constants import * To: try: f = open("Constants.py", "r") lines = f.readlines() for line in lines: try: eval(compile(string.replace(line,"\n",""), "", "single")) except exceptions.StandardError, e: traceback.print_exc() f.close() except exceptions.StandardError, e: print "\n\n\n" + line + "\n\n\n" print e traceback.print_exc() f.close() so that these variables get defined in the namespace of my Pythoncard app by compiling each expression and evaluating it dynamically. Now, the interesting thing is that the app runs fine under python.exe and pythonw.exe, and even the py2exe-generated console .exe. But the windows .exe won't run. Apparently, no errors are occurring in the above block because no tracebacks are being printed. Any ideas what might be going wrong? Are there any known problems with dynamically evaluating compiled expressions in a py2exe app? FYI - I tried using execfile("Constants.py") instead of evaluating individual lines, and the result is identical: runs fine under python.exe, pythonw.exe, and the py2exe-generated console .exe, but the windows .exe won't run. Thanks, Tim |