Hi, there has been a problem in blender3d for 6~ years or so thats eluded me, I decided to look into today. - Whenever the a script raises a warnings python prints out binary garbage in the console. Some users complain when they run python games in blender they get beeps coming from the PC speaker.
It turns out that _warning.c's setup_context() is taking the first value of argv (line 534 in 2.6.2), which in our case is the blender binary. then some part of the binary is printed to the console. Apart from the beeps and not being helpful this also can mess up the console's state - a like "cat /dev/random" might. But the real problem is that warnings expect a file to exist, in blender we have our own internal text's that dont have a corresponding file on disk, so setting __file__ in the global dict will just point to a location that doesn't exist. It surprises me that warnings do this since exceptions work as expected, printing useful stack traces from our built in texts. Incase this helps, the scripts are converted into a buffer and run like this... text->compiled = Py_CompileString( buf, text->id.name+2, Py_file_input ); PyEval_EvalCode( text->compiled, globaldict, globaldict ); Does anyone know of a workaround for this? Im sure there are other cases where you may want to run compiled code that isnt related to a file. -- - Campbell _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com