From: Greg.mpls@... Date: 2018-04-13T03:22:02+00:00 Subject: [ruby-core:86539] [Ruby trunk Bug#14687] TestM17N#test_str_dump, String.dump, frozen-string Issue #14687 has been reported by MSP-Greg (Greg L). ---------------------------------------- Bug #14687: TestM17N#test_str_dump, String.dump, frozen-string https://bugs.ruby-lang.org/issues/14687 * Author: MSP-Greg (Greg L) * Status: Open * Priority: Normal * Assignee: * Target version: * ruby -v: * Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN ---------------------------------------- The test `TestM17N#test_str_dump` located in `test/ruby/test_m17n.rb` (link at https://github.com/ruby/ruby/blob/83c961665def138e78a66d8bef0b4fa1da49ac69/test/ruby/test_m17n.rb#L324-L363), fails when run with frozen-string. The test is similar to ```ruby def test_str_dump # Note: several array elements removed to shorten [ "\u3042".encode("UTF-16LE"), "\u3042".encode("UTF-16BE"), ].each do |str| assert_equal(str, eval(str.dump), "[ruby-dev:33142]") end end ``` Since the following ```ruby "\u3042".encode("UTF-16LE").dump #-> "B0".force_encoding("UTF-16LE") "\u3042".encode("UTF-16BE").dump #-> "0B".force_encoding("UTF-16BE") ``` When eval'd by the test, there is a failure due to the string being frozen. Not being a c type, not really sure what the solution is. Possibly change line 5969 of string.c from ``` static const char nonascii_suffix[] = ".force_encoding(\"%s\")"; ``` to ``` static const char nonascii_suffix[] = "dup.force_encoding(\"%s\")"; ``` Thanks, Greg -- https://bugs.ruby-lang.org/ Unsubscribe: