Actions
Bug #14687
closedTestM17N#test_str_dump, String.dump, frozen-string
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.6.0dev (2018-04-12 trunk 63140) [x64-mingw32]
Description
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
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
"\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
Updated by MSP-Greg (Greg L) about 6 years ago
- ruby -v set to ruby 2.6.0dev (2018-04-12 trunk 63140) [x64-mingw32]
Updated by nobu (Nobuyoshi Nakada) about 6 years ago
- Status changed from Open to Closed
Applied in changeset trunk|r63164.
string.c: fix dumped suffix
- string.c (rb_str_dump): get rid of an error on evaling with
frozen-string-literal enabled. [ruby-core:86539] [Bug #14687]
Updated by nobu (Nobuyoshi Nakada) about 6 years ago
- Backport changed from 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN to 2.3: REQUIRED, 2.4: REQUIRED, 2.5: REQUIRED
Actions
Like0
Like0Like0Like0