[ruby-dev:46870] Re: [ruby-changes:26796] nobu:r38848 (trunk): win32ole.rb: use TracePoint
From:
SASADA Koichi <ko1@...>
Date:
2013-01-16 16:12:58 UTC
List:
ruby-dev #46870
中田さん: この変更ですが,TracePoint をこういう目的に使って良いか自信がないので, - win32ole は元に戻す - テストは,win32ole が require されていたら skip する というふうにしませんか? どちらかというと,svar の扱いをどうにかするか,というほうがいいかと 思っています. (2013/01/16 18:45), nobu wrote: > nobu 2013-01-16 18:45:48 +0900 (Wed, 16 Jan 2013) > > New Revision: 38848 > > http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=38848 > > Log: > win32ole.rb: use TracePoint > > * ext/win32ole/lib/win32ole.rb: use TracePoint to hook all thread > creation not only by Thread.new and to get rid of interference with > svar scope. [Bug #7681] [ruby-core:51365] > > Modified files: > trunk/ChangeLog > trunk/ext/win32ole/lib/win32ole.rb > trunk/test/win32ole/test_thread.rb > > Index: ChangeLog > =================================================================== > --- ChangeLog (revision 38847) > +++ ChangeLog (revision 38848) > @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 > +Wed Jan 16 18:45:46 2013 Nobuyoshi Nakada <[email protected]> > + > + * ext/win32ole/lib/win32ole.rb: use TracePoint to hook all thread > + creation not only by Thread.new and to get rid of interference with > + svar scope. [Bug #7681] [ruby-core:51365] > + > Wed Jan 16 09:35:53 2013 Eric Hodel <[email protected]> > > * .document: Removed extra space > Index: ext/win32ole/lib/win32ole.rb > =================================================================== > --- ext/win32ole/lib/win32ole.rb (revision 38847) > +++ ext/win32ole/lib/win32ole.rb (revision 38848) > @@ -3,20 +3,5 @@ require 'win32ole.so' https://github.com/ruby/ruby/blob/trunk/ext/win32ole/lib/win32ole.rb#L3 > # re-define Thread#initialize > # bug #2618(ruby-core:27634) > > -class Thread > - alias :org_initialize :initialize > - def initialize(*arg, &block) > - if block > - org_initialize(*arg) { > - WIN32OLE.ole_initialize > - begin > - block.call(*arg) > - ensure > - WIN32OLE.ole_uninitialize > - end > - } > - else > - org_initialize(*arg) > - end > - end > -end > +TracePoint.trace(:thread_begin) {WIN32OLE.ole_initialize} > +TracePoint.trace(:thread_end) {WIN32OLE.ole_uninitialize} > Index: test/win32ole/test_thread.rb > =================================================================== > --- test/win32ole/test_thread.rb (revision 38847) > +++ test/win32ole/test_thread.rb (revision 38848) > @@ -9,12 +9,25 @@ if defined?(WIN32OLE) https://github.com/ruby/ruby/blob/trunk/test/win32ole/test_thread.rb#L9 > # > # test for Bug #2618(ruby-core:27634) > # > - def test_creating_win32ole_object_in_thread > - t = Thread.new do > - dict = WIN32OLE.new('Scripting.Dictionary') > - assert(true) > - end > - t.join > + def assert_creating_win32ole_object_in_thread(meth) > + t = Thread.__send__(meth) { > + WIN32OLE.new('Scripting.Dictionary') > + } > + assert_nothing_raised(WIN32OLERuntimeError, "[Bug #2618] Thread.#{meth}") { > + t.join > + } > + end > + > + def test_creating_win32ole_object_in_thread_new > + assert_creating_win32ole_object_in_thread(:new) > + end > + > + def test_creating_win32ole_object_in_thread_start > + assert_creating_win32ole_object_in_thread(:start) > + end > + > + def test_creating_win32ole_object_in_thread_fork > + assert_creating_win32ole_object_in_thread(:fork) > end > end > end > > -- > ML: [email protected] > Info: http://www.atdot.net/~ko1/quickml/ > -- // SASADA Koichi at atdot dot net