[Bf-committers] importing bl_info

Campbell Barton ideasman42 at gmail.com
Fri Apr 27 06:52:47 CEST 2012


On Fri, Apr 27, 2012 at 2:29 PM, Yousef Hurfoush <bat3a at msn.com> wrote:
>
>> With bl_info - you probably want to load it without running any
>> blender code (importing bpy for eg).
>>
>> check on addon_utils.py, fake_module().
> thanks, i checked it, and it does the same almost :) as my script here:
> http://www.pasteall.org/31285/python
>
> so in the end, no clean way to do it.
>
> Regards
> Yousef Harfoush
> bat3a at msn.com

Wouldn't say that - IMHO using AST is clean enough,
checked your code and while its doing roughly the same thing by
scanning for bl_info, but its using eval() which means someone could
create a malicious bl_info that runs code on your system.

You can avoid scanning for bl_info with ast, just load the python file
data and extract the dict (without execution), when fake_module(...,
speedy=False), this is what happens, it just turned out to be faster
to only parse the file header.


More information about the Bf-committers mailing list