[Python-Dev] Warnings when no file exists. (original) (raw)

Campbell Barton ideasman42 at gmail.com
Fri May 29 07:05:51 CEST 2009


Hi, there has been a problem in blender3d for 6~ years or so thats eluded me, I decided to look into today.

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.

--



More information about the Python-Dev mailing list