[#67346] Future of test suites for Ruby — Charles Oliver Nutter <headius@...>
I'll try to be brief so we can discuss all this. tl;dr: RubySpec is
19 messages
2015/01/05
[#67353] Re: Future of test suites for Ruby
— Tanaka Akira <akr@...>
2015/01/05
2015-01-06 7:18 GMT+09:00 Charles Oliver Nutter <headius@headius.com>:
[#67444] [ruby-trunk - Feature #10718] [Open] IO#close should not raise IOError on closed IO objects. — akr@...
Issue #10718 has been reported by Akira Tanaka.
3 messages
2015/01/09
[#67689] Keyword Arguments — Anthony Crumley <anthony.crumley@...>
Please forgive my ignorance as I am new to MRI development and am still
5 messages
2015/01/20
[#67733] [ruby-trunk - Bug #10761] Marshal.dump 100% slower in 2.2.0 vs 2.1.5 — normalperson@...
Issue #10761 has been updated by Eric Wong.
4 messages
2015/01/21
[#67736] Re: [ruby-trunk - Bug #10761] Marshal.dump 100% slower in 2.2.0 vs 2.1.5
— Eric Wong <normalperson@...>
2015/01/22
normalperson@yhbt.net wrote:
[#67772] Preventing Redundant Email Messages — Jeremy Evans <code@...>
For a long time, I've wondered why I sometimes receive redundant email
5 messages
2015/01/23
[ruby-core:67386] [ruby-trunk - Bug #10705] [Open] JSON::ParserError#message is wrong encoding (ASCII-8BIT)
From:
josh.cheek@...
Date:
2015-01-07 11:41:33 UTC
List:
ruby-core #67386
Issue #10705 has been reported by Josh Cheek.
----------------------------------------
Bug #10705: JSON::ParserError#message is wrong encoding (ASCII-8BIT)
https://bugs.ruby-lang.org/issues/10705
* Author: Josh Cheek
* Status: Open
* Priority: Normal
* Assignee:
* Category:
* Target version:
* ruby -v: ruby 2.3.0dev (2015-01-06 trunk 49159) [x86_64-darwin13]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
JSON::ParserError#message is wrong encoding (ASCII-8BIT). I would expect the error to be whatever the internal encoding is (in my case, utf8), perhaps inspecting the string in the error message such that all characters would be valid in that encoding.
Here is an example of where it becomes an issue:
~~~ruby
# encoding: utf-8
require 'json' # => true
json = JSON.dump("√") # => "\"√\""
begin
result = JSON.parse(json)
puts "PARSED: #{result.inspect}"
rescue JSON::ParserError => e
`ruby -v` # => "ruby 2.3.0dev (2015-01-06 trunk 49159) [x86_64-darwin13]\n"
json.encoding # => #<Encoding:UTF-8>
e.message.encoding # => #<Encoding:ASCII-8BIT>
e.message # => "757: unexpected token at '\"\xE2\x88\x9A\"'"
puts "Could not parse #{json.inspect} because #{e.message}" # ~> Encoding::CompatibilityError: incompatible character encodings: UTF-8 and ASCII-8BIT
end
# ~> Encoding::CompatibilityError
# ~> incompatible character encodings: UTF-8 and ASCII-8BIT
# ~>
# ~> f9.rb:13:in `rescue in <main>'
# ~> f9.rb:5:in `<main>'
~~~
If the parsed string doesn't have a multibyte unicode character, it still happens, but fixes itself when it comes in contact with another string, since all its bytes are within the ASCII range.
Documented the actual use case and debugging [here](https://github.com/JoshCheek/seeing_is_believing/issues/46#issuecomment-69007428).
(side thought: should I open another bug since it generates invalid JSON?)
--
https://bugs.ruby-lang.org/