Issue #5012 has been reported by Kazuki Tsujimoto.
Bug #5012: Timeオブジェクト間で特異オブジェクトが共有される
Author: Kazuki Tsujimoto
Status: Open
Priority: Normal
Assignee:
Category: lib
Target version:
ruby -v: ruby 1.9.3dev (2011-07-10 trunk 32482) [x86_64-linux]
=begin
辻本です。
Time#getlocalなどによって返されるTimeオブジェクトが、
レシーバと特異オブジェクトを共有してしまっています。
t0 = Time.now
class <<t0; end
t1 = t0.getlocal
def t0.m
0
end
p t0.m # => 0
p t1.m # => 0
以下のパッチでどうでしょうか。
diff --git a/time.c b/time.c
index 5dbf9b2…eb49ef2 100644
— a/time.c
+++ b/time.c
@@ -3426,7 +3426,7 @@ time_init_copy(VALUE copy, VALUE time)
static VALUE
time_dup(VALUE time)
{
- VALUE dup = time_s_alloc(CLASS_OF(time));
- VALUE dup = time_s_alloc(rb_obj_class(time));
time_init_copy(dup, time);
return dup;
}
=end
Issue #5012 has been updated by Motohiro KOSAKI.
Target version set to 1.9.3
Bug #5012: Timeオブジェクト間で特異オブジェクトが共有される
Author: Kazuki Tsujimoto
Status: Open
Priority: Normal
Assignee:
Category: lib
Target version: 1.9.3
ruby -v: ruby 1.9.3dev (2011-07-10 trunk 32482) [x86_64-linux]
=begin
辻本です。
Time#getlocalなどによって返されるTimeオブジェクトが、
レシーバと特異オブジェクトを共有してしまっています。
t0 = Time.now
class <<t0; end
t1 = t0.getlocal
def t0.m
0
end
p t0.m # => 0
p t1.m # => 0
以下のパッチでどうでしょうか。
diff --git a/time.c b/time.c
index 5dbf9b2…eb49ef2 100644
— a/time.c
+++ b/time.c
@@ -3426,7 +3426,7 @@ time_init_copy(VALUE copy, VALUE time)
static VALUE
time_dup(VALUE time)
{
- VALUE dup = time_s_alloc(CLASS_OF(time));
- VALUE dup = time_s_alloc(rb_obj_class(time));
time_init_copy(dup, time);
return dup;
}
=end
Issue #5012 has been updated by Nobuyoshi N…
Status changed from Open to Assigned
Assignee set to Motohiro KOSAKI
Bug #5012: Timeオブジェクト間で特異オブジェクトが共有される
Author: Kazuki Tsujimoto
Status: Assigned
Priority: Normal
Assignee: Motohiro KOSAKI
Category: lib
Target version: 1.9.3
ruby -v: ruby 1.9.3dev (2011-07-10 trunk 32482) [x86_64-linux]
=begin
辻本です。
Time#getlocalなどによって返されるTimeオブジェクトが、
レシーバと特異オブジェクトを共有してしまっています。
t0 = Time.now
class <<t0; end
t1 = t0.getlocal
def t0.m
0
end
p t0.m # => 0
p t1.m # => 0
以下のパッチでどうでしょうか。
diff --git a/time.c b/time.c
index 5dbf9b2…eb49ef2 100644
— a/time.c
+++ b/time.c
@@ -3426,7 +3426,7 @@ time_init_copy(VALUE copy, VALUE time)
static VALUE
time_dup(VALUE time)
{
- VALUE dup = time_s_alloc(CLASS_OF(time));
- VALUE dup = time_s_alloc(rb_obj_class(time));
time_init_copy(dup, time);
return dup;
}
=end
Issue #5012 has been updated by Motohiro KOSAKI.
ありがとうございます。よさげに見えたので1.9.3ブランチにも入れてしまいました。
Bug #5012: Timeオブジェクト間で特異オブジェクトが共有される
Author: Kazuki Tsujimoto
Status: Closed
Priority: Normal
Assignee: Motohiro KOSAKI
Category: lib
Target version: 1.9.3
ruby -v: ruby 1.9.3dev (2011-07-10 trunk 32482) [x86_64-linux]
=begin
辻本です。
Time#getlocalなどによって返されるTimeオブジェクトが、
レシーバと特異オブジェクトを共有してしまっています。
t0 = Time.now
class <<t0; end
t1 = t0.getlocal
def t0.m
0
end
p t0.m # => 0
p t1.m # => 0
以下のパッチでどうでしょうか。
diff --git a/time.c b/time.c
index 5dbf9b2…eb49ef2 100644
— a/time.c
+++ b/time.c
@@ -3426,7 +3426,7 @@ time_init_copy(VALUE copy, VALUE time)
static VALUE
time_dup(VALUE time)
{
- VALUE dup = time_s_alloc(CLASS_OF(time));
- VALUE dup = time_s_alloc(rb_obj_class(time));
time_init_copy(dup, time);
return dup;
}
=end