summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/ostruct.rb5
-rw-r--r--test/ostruct/test_ostruct.rb9
-rw-r--r--version.h2
3 files changed, 14 insertions, 2 deletions
diff --git a/lib/ostruct.rb b/lib/ostruct.rb
index 17efcdc8d3..bae0f3aac5 100644
--- a/lib/ostruct.rb
+++ b/lib/ostruct.rb
@@ -73,7 +73,10 @@
class OpenStruct
# :nodoc:
class << self
- alias allocate new
+ def allocate
+ (x = super).instance_variable_set(:@table, {})
+ x
+ end
end
#
diff --git a/test/ostruct/test_ostruct.rb b/test/ostruct/test_ostruct.rb
index 85fdd66ccd..0504efbf76 100644
--- a/test/ostruct/test_ostruct.rb
+++ b/test/ostruct/test_ostruct.rb
@@ -181,4 +181,13 @@ class TC_OpenStruct < Test::Unit::TestCase
os.foo = 44
assert_equal(43, os.foo)
end
+
+ def test_allocate_subclass
+ bug = '[ruby-core:80292] [Bug #13358] allocate should not call initialize'
+ c = Class.new(OpenStruct) {
+ def initialize(x,y={})super(y);end
+ }
+ os = assert_nothing_raised(ArgumentError, bug) {c.allocate}
+ assert_instance_of(c, os)
+ end
end
diff --git a/version.h b/version.h
index e0173af023..f38fa2d3f8 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.3.3"
#define RUBY_RELEASE_DATE "2017-03-28"
-#define RUBY_PATCHLEVEL 270
+#define RUBY_PATCHLEVEL 271
#define RUBY_RELEASE_YEAR 2017
#define RUBY_RELEASE_MONTH 3