[Bf-committers] Patch: removing use of exec() and eval() from python source
theeth at yahoo.com
Wed Oct 21 05:35:05 CEST 2009
--- On Tue, 10/20/09, Mathias Panzenböck <grosser.meister.morti at gmx.net> wrote:
> From: Mathias Panzenböck <grosser.meister.morti at gmx.net>
> Subject: Re: [Bf-committers] Patch: removing use of exec() and eval() from python source
> To: bf-committers at blender.org
> Received: Tuesday, October 20, 2009, 11:22 PM
> On 10/21/2009 02:03 AM, Martin
> Poirier wrote:
> > --- On Tue, 10/20/09, Mathias Panzenböck <grosser.meister.morti at gmx.net>
> >> Anyway, "evaluating the value means it can convert
> >> whatever type is needed
> >> from a string property" is just nonsense when you
> use %d
> >> and %f format strings
> >> (as is done right now) because of:
> > All of them use - exec("[...] = %s" % value) - right
> now, so the string property is evaluate. (as it would do in
> your 3rd example earlier, except it doesn't need to convert
> to string since it's already assured to be one).
> Ok, I don't want to waste more of your time on this, just
> one last note:
> The current code does NOT use %s everywhere. Look at:
> and you'll see things like:
> exec("context.%s=%f" % (self.path, self.value))
Ah, yes, sorry about that, previous revisions (6 days ago) used a single operator with strings everywhere.
> which will raise a TypeError when self.value is a string.
That will never happen, the rna type definition prevents it.
> Still, %r would be better, especially in the string case.
Only when the value is not a string, which we are assured is never going to be the case.
Actually, now that there's an operator for each type, what you suggested earlier can be used:
exec("context.%s= self.value" % self.path)
(while waiting for rna path selectors in the api)
Make your browsing faster, safer, and easier with the new Internet Explorer® 8. Optimized for Yahoo! Get it Now for Free! at http://downloads.yahoo.com/ca/internetexplorer/
More information about the Bf-committers