List comprehension - NameError: name '_[1]' is not defined ?

mario ruggier mario.ruggier at
Fri Jan 16 18:45:34 CET 2009

On Jan 16, 1:35 pm, ajaksu <aja... at> wrote:
> On Jan 16, 5:09 am, mario ruggier <mario.rugg... at> wrote:
> > Laboriously doing all these
> > checks on each expr eval will be very performance heavy, so I hope to
> > be able to limit access to all these more efficiently. Suggestions?
> None regarding the general issue, a try:except to handle this one:
> '(x for x in ()).throw("bork")'

What is the potential security risk with this one?

To handle this and situations like the ones pointed out above on this
thread, I will probably affect the following change to the
evoque.evaluator.RestrictedEvaluator class, and that is to replace the
'if name.find("__")!=-1:' with an where the re is defined

    restricted = re.compile(r"|\.".join([
        "__", "func_", "f_", "im_", "tb_", "gi_", "throw"]))

and the test becomes simply:


All the above attempts will be blocked this way. Any other disallow-
sub-strings to add to the list above?

And thanks a lot Daniel, need to find a way to get somebeer over to
ya... ;-)


More information about the Python-list mailing list