summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-11-28 07:20:40 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-11-28 07:20:40 +0000
commit7149859bc35cfe7497a1e98118f22a1628e8703d (patch)
tree4b27d0d86783576fe99e59c394e717e54628610b
parent3412d1016a4a166d7e7bf32e56bcde5cc25f19ae (diff)
merge revision(s) 48160: [Backport #10432]
* proc.c (method_proc): the receiver of binding from method should be same as the receiver of the method. [ruby-core:65917] [Bug #10432] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@48633 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog6
-rw-r--r--proc.c10
-rw-r--r--test/ruby/test_proc.rb5
-rw-r--r--version.h2
4 files changed, 21 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 3c90a4e5e5..6889c2bd99 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Fri Nov 28 16:18:44 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * proc.c (method_proc): the receiver of binding from method should
+ be same as the receiver of the method.
+ [ruby-core:65917] [Bug #10432]
+
Fri Nov 28 16:12:22 2014 NARUSE, Yui <naruse@ruby-lang.org>
* lib/net/http.rb (Net::HTTP.proxy_uri): use initializer instead
diff --git a/proc.c b/proc.c
index d8f0b28e1a..8d18e2c3db 100644
--- a/proc.c
+++ b/proc.c
@@ -2034,7 +2034,10 @@ static VALUE
method_proc(VALUE method)
{
VALUE procval;
+ struct METHOD *meth;
rb_proc_t *proc;
+ rb_env_t *env;
+
/*
* class Method
* def to_proc
@@ -2044,9 +2047,16 @@ method_proc(VALUE method)
* end
* end
*/
+ TypedData_Get_Struct(method, struct METHOD, &method_data_type, meth);
procval = rb_iterate(mlambda, 0, bmcall, method);
GetProcPtr(procval, proc);
proc->is_from_method = 1;
+ proc->block.self = meth->recv;
+ proc->block.klass = meth->defined_class;
+ GetEnvPtr(proc->envval, env);
+ env->block.self = meth->recv;
+ env->block.klass = meth->defined_class;
+ env->block.iseq = method_get_iseq(meth->me->def);
return procval;
}
diff --git a/test/ruby/test_proc.rb b/test/ruby/test_proc.rb
index 2db9108534..da7f07ef6c 100644
--- a/test/ruby/test_proc.rb
+++ b/test/ruby/test_proc.rb
@@ -179,7 +179,10 @@ class TestProc < Test::Unit::TestCase
def test_method_to_proc
b = block()
assert_equal "OK", b.call
- assert_instance_of(Binding, b.binding, '[ruby-core:25589]')
+ b = b.binding
+ assert_instance_of(Binding, b, '[ruby-core:25589]')
+ bug10432 = '[ruby-core:65919] [Bug #10432]'
+ assert_same(self, b.eval("self"), bug10432)
end
def test_block_given_method
diff --git a/version.h b/version.h
index 48a0af5d4a..ec4a00c26b 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.0.0"
#define RUBY_RELEASE_DATE "2014-11-28"
-#define RUBY_PATCHLEVEL 602
+#define RUBY_PATCHLEVEL 603
#define RUBY_RELEASE_YEAR 2014
#define RUBY_RELEASE_MONTH 11