Project

General

Profile

Actions

Bug #8611

closed

Minitest encoding problems.

Added by Anonymous almost 11 years ago. Updated almost 5 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
2.0.0.latest patch
Backport:
[ruby-core:55850]

Description

A long standing annoying misfeature of minitest is the problem with encoding, which I have solved by patching the backtrace.join line in units.rb, #puke method with map{ |str| str.force_encoding( "UTF-8 ) }. If I don't do this, the tests in irb won't run, instead I get a complaint about "ASCII 8" versus "UTF-8" incompatibility. Only happens when one extensively uses UTF characters when coding, an annoying intermittent error.

Updated by Anonymous almost 11 years ago

Sorry for a terse report and lack of supporting materials, I'm extremely busy now.

Updated by naruse (Yui NARUSE) almost 11 years ago

  • Status changed from Open to Feedback

You know, this must have reproducible code.

Updated by Anonymous almost 11 years ago

All right, I am no longer getting the same error since I patched it for myself, but to illustrate what I am talking about, here is another way to crash irb in basically the same way, pointing to a wider problem. It can be illustrated with Pyper gem that I wrote as follows:

gem install 'pyper'
a = [1, 3, 4, 3, 0, 3, 1]
a.τsπ( :uniq ).χOixπ.χriXgζmEπ # consider it fuzz testing :-)

NoMethodError ensues, that crashes the irb:

NoMethodError: undefined method map' for 0:Fixnum /usr/local/lib/ruby/2.0.0/irb.rb:526:in join': incompatible character encodings: ASCII-8BIT and UTF-8 (Encoding::CompatibilityError)
from /usr/local/lib/ruby/2.0.0/irb.rb:526:in block (2 levels) in eval_input' from /usr/local/lib/ruby/2.0.0/irb.rb:624:in signal_status'
from /usr/local/lib/ruby/2.0.0/irb.rb:489:in block in eval_input' from /usr/local/lib/ruby/2.0.0/irb/ruby-lex.rb:247:in block (2 levels) in each_top_level_statement'
from /usr/local/lib/ruby/2.0.0/irb/ruby-lex.rb:233:in loop' from /usr/local/lib/ruby/2.0.0/irb/ruby-lex.rb:233:in block in each_top_level_statement'
from /usr/local/lib/ruby/2.0.0/irb/ruby-lex.rb:232:in catch' from /usr/local/lib/ruby/2.0.0/irb/ruby-lex.rb:232:in each_top_level_statement'
from /usr/local/lib/ruby/2.0.0/irb.rb:488:in eval_input' from /usr/local/lib/ruby/2.0.0/irb.rb:397:in block in start'
from /usr/local/lib/ruby/2.0.0/irb.rb:396:in catch' from /usr/local/lib/ruby/2.0.0/irb.rb:396:in start'
from /usr/local/bin/irb:12:in `'

Note that eg.

a.τsπ( :uniq ).χOixπ.χriXgζqτ.tap { fail NoMethodError }

raises NoMethodError without crashing the irb.

Updated by jeremyevans0 (Jeremy Evans) almost 5 years ago

  • Status changed from Feedback to Closed
  • Backport deleted (1.9.3: UNKNOWN, 2.0.0: UNKNOWN)

The issue you described with irb crashing was fixed between 2.0 and 2.1:

$ irb20 -rpyper
irb(main):001:0> a = [1, 3, 4, 3, 0, 3, 1]
=> [1, 3, 4, 3, 0, 3, 1]
irb(main):002:0> a.τsπ( :uniq ).χOixπ.χriXgζmEπ
NoMethodError: undefined method `map' for 0:Fixnum
/usr/local/lib/ruby/2.0/irb.rb:526:in `join': incompatible character encodings: ASCII-8BIT and UTF-8 (Encoding::CompatibilityError)
        from /usr/local/lib/ruby/2.0/irb.rb:526:in `block (2 levels) in eval_input'
        from /usr/local/lib/ruby/2.0/irb.rb:624:in `signal_status'
        from /usr/local/lib/ruby/2.0/irb.rb:489:in `block in eval_input'
        from /usr/local/lib/ruby/2.0/irb/ruby-lex.rb:247:in `block (2 levels) in each_top_level_statement'
        from /usr/local/lib/ruby/2.0/irb/ruby-lex.rb:233:in `loop'
        from /usr/local/lib/ruby/2.0/irb/ruby-lex.rb:233:in `block in each_top_level_statement'
        from /usr/local/lib/ruby/2.0/irb/ruby-lex.rb:232:in `catch'
        from /usr/local/lib/ruby/2.0/irb/ruby-lex.rb:232:in `each_top_level_statement'
        from /usr/local/lib/ruby/2.0/irb.rb:488:in `eval_input'
        from /usr/local/lib/ruby/2.0/irb.rb:397:in `block in start'
        from /usr/local/lib/ruby/2.0/irb.rb:396:in `catch'
        from /usr/local/lib/ruby/2.0/irb.rb:396:in `start'
        from /usr/local/bin/irb20:12:in `<main>'
$ irb21 -rpyper
irb(main):001:0> a = [1, 3, 4, 3, 0, 3, 1]
=> [1, 3, 4, 3, 0, 3, 1]
irb(main):002:0> a.τsπ( :uniq ).χOixπ.χriXgζmEπ
NoMethodError: undefined method `map' for 0:Fixnum
        from (eval):12:in `block in χriXgζmEπ'
        from (eval):6:in `map'
        from (eval):6:in `with_index'
        from (eval):6:in `χriXgζmEπ'
        from /usr/local/lib/ruby/gems/2.6/gems/pyper-2.0.1/lib/pyper.rb:165:in `method_missing'
        from (irb):2
        from /usr/local/bin/irb21:11:in `<main>'
irb(main):003:0>
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0