[#100689] [Ruby master Feature#17303] Make webrick to bundled gems or remove from stdlib — hsbt@...
Issue #17303 has been reported by hsbt (Hiroshi SHIBATA).
11 messages
2020/11/02
[#100852] [Ruby master Feature#17326] Add Kernel#must! to the standard library — zimmerman.jake@...
Issue #17326 has been reported by jez (Jake Zimmerman).
24 messages
2020/11/14
[#100930] [Ruby master Feature#17333] Enumerable#many? — masafumi.o1988@...
Issue #17333 has been reported by okuramasafumi (Masafumi OKURA).
10 messages
2020/11/18
[#101071] [Ruby master Feature#17342] Hash#fetch_set — hunter_spawn@...
Issue #17342 has been reported by MaxLap (Maxime Lapointe).
26 messages
2020/11/25
[ruby-core:100726] [Ruby master Bug#17308] RubyVM::InstructionSequence.compile_file doesn't use the same default encoding than Kernel.load
From:
jean.boussier@...
Date:
2020-11-06 10:19:36 UTC
List:
ruby-core #100726
Issue #17308 has been reported by byroot (Jean Boussier).
----------------------------------------
Bug #17308: RubyVM::InstructionSequence.compile_file doesn't use the same default encoding than Kernel.load
https://bugs.ruby-lang.org/issues/17308
* Author: byroot (Jean Boussier)
* Status: Open
* Priority: Normal
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN
----------------------------------------
```ruby
def test_compile_file_encoding
Tempfile.create(%w"test_iseq .rb") do |f|
f.puts '{ " => "Th", "゜" => "ss", "燿 => "a" }'
f.close
previous_external = Encoding.default_external
Encoding.default_external = Encoding::US_ASCII
begin
load f.path
RubyVM::InstructionSequence.compile_file(f.path)
ensure
Encoding.default_external = previous_external
end
end
end
```
In the above test case, `load` assumes that the source file is `UTF-8` whereas `compile_file` uses `default_external` causing various problems:
```
[1/1] TestISeq#test_compile_file_encoding test_iseq20201106-96756-2c0cz.rb:1: warning: key "" is duplicated and overwritten on line 1
test_iseq20201106-96756-2c0cz.rb:1: warning: key "" is duplicated and overwritten on line 1
= 0.00 s
1) Error:
TestISeq#test_compile_file_encoding:
SyntaxError: test_iseq20201106-96756-2c0cz.rb:1: invalid multibyte char (US-ASCII)
test_iseq20201106-96756-2c0cz.rb:1: invalid multibyte char (US-ASCII)
test_iseq20201106-96756-2c0cz.rb:1: invalid multibyte char (US-ASCII)
test_iseq20201106-96756-2c0cz.rb:1: invalid multibyte char (US-ASCII)
test_iseq20201106-96756-2c0cz.rb:1: invalid multibyte char (US-ASCII)
test_iseq20201106-96756-2c0cz.rb:1: invalid multibyte char (US-ASCII)
ruby/test/ruby/test_iseq.rb:283:in `compile_file'
ruby/test/ruby/test_iseq.rb:283:in `block in test_compile_file_encoding'
ruby/lib/tempfile.rb:358:in `create'
ruby/test/ruby/test_iseq.rb:275:in `test_compile_file_encoding'
```
I believe `compile_file` should be consistent with `load`, or at least properly default to `UTF-8` like load does.
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>