Project

General

Profile

Actions

Bug #1381

closed

Confusing Encoding Error

Added by JEG2 (James Gray) over 15 years ago. Updated over 13 years ago.

Status:
Closed
Target version:
ruby -v:
ruby 1.9.2dev (2009-04-13) [i386-darwin9.6.0]
Backport:
[ruby-core:23208]

Description

=begin
When I reuse a Regexp object, the Encoding seems unchanged but an error message can report something different from what I am seeing:

 $ cat enc_error_bug.rb 
 re = /./
 puts re.encoding.name
 "a".encode("ASCII-8BIT") =~ re if $DEBUG
 puts re.encoding.name
 "a".encode("UTF-16BE") =~ re
 $ ruby enc_error_bug.rb 
 US-ASCII
 US-ASCII
 enc_error_bug.rb:5:in `=~': incompatible encoding regexp match (US-ASCII regexp with UTF-16BE string) (Encoding::CompatibilityError)
 	from enc_error_bug.rb:5:in `<main>'
 $ ruby -d enc_error_bug.rb 
 US-ASCII
 US-ASCII
 Exception `Encoding::CompatibilityError' at enc_error_bug.rb:5 - incompatible encoding regexp match (ASCII-8BIT regexp with UTF-16BE string)
 enc_error_bug.rb:5:in `=~': incompatible encoding regexp match (ASCII-8BIT regexp with UTF-16BE string) (Encoding::CompatibilityError)
 	from enc_error_bug.rb:5:in `<main>'

Notice how the Regexp's Encoding stays US-ASCII, but the error message calls it ASCII-8BIT if I first match it as against an ASCII-8BIT String.
=end


Files

without_remember_the_previous_encoding.patch (449 Bytes) without_remember_the_previous_encoding.patch ujihisa (Tatsuhiro Ujihisa), 04/15/2009 07:52 PM
Actions #1

Updated by ujihisa (Tatsuhiro Ujihisa) over 15 years ago

=begin
This patch fix the problem, but may cause another one. I don't understand the purpose of the original code.

=end

Actions #2

Updated by yugui (Yuki Sonoda) over 15 years ago

  • Assignee set to naruse (Yui NARUSE)

=begin

=end

Actions #3

Updated by naruse (Yui NARUSE) over 15 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

=begin
Applied in changeset r24197.
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0