Bug #2955

File.expand_path raises unexpected CompatibilityError

Added by sakuro (Sakuro OZAWA) about 2 years ago. Updated about 1 year ago.

[ruby-core:28635]
Status:Closed Start date:03/13/2010
Priority:Normal Due date:
Assignee:- % Done:

100%

Category:-
Target version:-
ruby -v:ruby 1.9.2dev (2010-03-13 trunk 26902) [x86_64-darwin10.2.0]

Description

$ ./ruby -Ilib -e "p Encoding.find('filesystem')"
#<Encoding:UTF-8>
./ruby -Ilib -e "p 'あ'.encoding.ascii_compatible?"                        
true
$ ./ruby -Ilib -e "p File.expand_path('あ', '/')"
"/あ"

The above is ok but

$ ./ruby -Ilib -e "p File.expand_path('あ', '/'.force_encoding('US-ASCII'))"
-e:1:in `expand_path': incompatible character encodings: UTF-8 and US-ASCII (Encoding::CompatibilityError)
	from -e:1:in `<main>'

For me this is unexpected one.

Associated revisions

Revision 26909
Added by matz (Yukihiro Matsumoto) about 2 years ago

* file.c (file_expand_path): should not just copy the encoding from fname. [ruby-core:28635] * file.c (EXPAND_PATH_BUFFER): set filesystem_encoding, not usascii for path buffer.

History

Updated by matz (Yukihiro Matsumoto) about 2 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100
This issue was solved with changeset r26909.
Sakuro, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.

Also available in: Atom PDF