Re: Strange behavior with RubyAuthenHandler on ruby 1.8.1 + modruby 1.0.7

Shugo Maeda <[email protected]>
Newsgroups gmane.comp.apache.mod-ruby
Message-ID <[email protected]>
Hello,

At Thu, 01 Apr 2004 18:54:16 +0200,
LHERBIER Lois <[email protected]> wrote:
> We have an intranet developped with ruby 1.6.7 + modruby 1.0.3 + apache 
> 1.3.x and we want to use ruby 1.8.1 + modruby 1.0.7 + apache 1.3.x.
> But we have a problem with RubyAuthenHandler on this new plateform. I 
> have spent a long time identifying this "bug".
(snip)
> Can you please help me to find the problem ?

In ruby-1.8, the behaviour of include in scripts loaded by
load(filename, true) seems to be changed from ruby-1.6.

For example, the followint test works on ruby-1.6, but doesn't
work in ruby-1.8.

--- b.rb ---
module A
  module B
  end
end
-----------
--- test.rb ---
p A::B
include A
p B
--------------

excelsior:/tmp$ ruby1.6 -v -r b -e 'load("./test.rb", true)'
ruby 1.6.8 (2003-07-09) [i386-linux]
A::B
A::B
excelsior:/tmp$ ruby1.8 -v -r b -e 'load("./test.rb", true)'
ruby 1.8.1 (2004-02-03) [i386-linux]
A::B
./test.rb:2: warning: main#include in the wrapped load is effective only for toplevel
./test.rb:3: uninitialized constant #<Module:0x402e8f48>::B (NameError)
        from -e:1:in `load'
        from -e:1

I proposed the following patch for ruby-1.8 to matz in the ruby-dev ML.
But I'm not sure that it works correctly in any situation.
Can you try it?

diff -u -r1.652 eval.c
--- eval.c	2 Apr 2004 02:36:47 -0000	1.652
+++ eval.c	2 Apr 2004 03:01:15 -0000
@@ -7222,8 +7222,7 @@
 {
     rb_secure(4);
     if (ruby_wrapper) {
-	rb_warn("main#include in the wrapped load is effective only for toplevel");
-	return rb_obj_extend(argc, argv, self);
+	return rb_mod_include(argc, argv, ruby_wrapper);
     }
     else {
 	return rb_mod_include(argc, argv, rb_cObject);

Regards,
Shugo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.