aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-07-19 06:39:01 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-07-19 06:39:01 +0000
commitb16e5cd6337cb68c1ae5c8a47fac251ec9940096 (patch)
tree53aac200b92c8e121fabd1f1ae65ffb765c015d1
parent547346914f98799fd45893f5572d2112afa27d0d (diff)
downloadruby-b16e5cd6337cb68c1ae5c8a47fac251ec9940096.tar.gz
variable.c: exclude private constants
* variable.c (rb_local_constants_i): exclude private constants when excluding inherited constants too. [Bug #12345] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55705 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--test/ruby/test_module.rb2
-rw-r--r--variable.c2
3 files changed, 8 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 7a82244201..23394ccd1c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Tue Jul 19 15:38:59 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * variable.c (rb_local_constants_i): exclude private constants
+ when excluding inherited constants too. [Bug #12345]
+
Sun Jul 17 23:42:00 2016 Kenta Murata <mrkn@mrkn.jp>
* numeric.c (num_finite_p, num_infinite_p): Add Numeric#finite? and
diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb
index 92c3dfd6eb..0f9351c57d 100644
--- a/test/ruby/test_module.rb
+++ b/test/ruby/test_module.rb
@@ -1423,6 +1423,8 @@ class TestModule < Test::Unit::TestCase
def test_constants_with_private_constant
assert_not_include(::TestModule.constants, :PrivateClass)
+ assert_not_include(::TestModule.constants(true), :PrivateClass)
+ assert_not_include(::TestModule.constants(false), :PrivateClass)
end
def test_toplevel_private_constant
diff --git a/variable.c b/variable.c
index 4d3222b5db..0966685690 100644
--- a/variable.c
+++ b/variable.c
@@ -2399,7 +2399,7 @@ sv_i(ID key, VALUE v, void *a)
static enum rb_id_table_iterator_result
rb_local_constants_i(ID const_name, VALUE const_value, void *ary)
{
- if (rb_is_const_id(const_name)) {
+ if (rb_is_const_id(const_name) && !RB_CONST_PRIVATE_P((rb_const_entry_t *)const_value)) {
rb_ary_push((VALUE)ary, ID2SYM(const_name));
}
return ID_TABLE_CONTINUE;