Bug #2955
File.expand_path raises unexpected CompatibilityError
| 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
* 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.