[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: [BUG?] $SAFE reset when proc called (1.8.4

Daniel Sheppard

3/5/2007 11:41:00 PM


> pr = lambda{ puts "my_safe_level=#{Thread.current.safe_level}" }
>
> th = Thread.new(pr) do |pr_|
> $SAFE = 4
> pr_.call
> end
> th.join
>
> $ ruby -v safe-test.rb
> ruby 1.8.4 (2005-12-24) [i386-mswin32]
> my_safe_level=0
>
> If this isn't a bug, does anyone know why this behavior would
> be desirable?

AFAIK, that's the desired behavior - the pr proc was created while
$SAFE=0 and will be executed in that $SAFE=0 context. That allows you to
give a Safe environment access to unsafe things.

Dan.

1 Answer

Bill Kelly

3/6/2007 12:10:00 AM

0

From: "Daniel Sheppard" <daniels@pronto.com.au>
>
> AFAIK, that's the desired behavior - the pr proc was created while
> $SAFE=0 and will be executed in that $SAFE=0 context. That allows you to
> give a Safe environment access to unsafe things.

Oh. I guess that is pretty cool. :-)

Just inconvenient in my particular situation, but I can work
around it.


Thanks,

Bill