From: "tenderlovemaking (Aaron Patterson)" Date: 2012-07-24T04:06:53+09:00 Subject: [ruby-core:46682] [ruby-trunk - Bug #6377] $LOADED_FEATURES entry via YAML is binary data? Issue #6377 has been updated by tenderlovemaking (Aaron Patterson). I'm not sure how or if I should fix this. There are two problems: 1) we lose encoding information, and 2) how do we decide what to consider "binary" or not. For #1, if we treat 7bit only ascii strings as "non-binary", it means that when we load the data back in, the string will be tagged as UTF-8 (since "raw" YAML strings are unicode). e.g. today this test passes, but if we treat 7bit ascii strings as non-binary, it will fail: s = "hello".encode('ASCII-8BIT') assert_equal s.encoding, YAML.load(YAML.dump(s)).encoding For #2, I'm not sure how we decide what is binary and what is not. Should strings that contain null bytes be considered binary? If so, we can't use the `ascii_only?` method: "\0".ascii_only? # => true Given the data loss from #1, and the hardship of #2, I don't think Psych should change. I'm open to suggestions for dealing with these problems. Nobu: Why are the paths on LOADED_FEATURES encoded as ASCII-8BIT? Shouldn't those paths be tagged with the filesystem encoding? ---------------------------------------- Bug #6377: $LOADED_FEATURES entry via YAML is binary data? https://bugs.ruby-lang.org/issues/6377#change-28347 Author: trans (Thomas Sawyer) Status: Assigned Priority: Normal Assignee: tenderlovemaking (Aaron Patterson) Category: lib Target version: 1.9.3 ruby -v: ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-linux] =begin While working with $LOADED_FEATURES, came across this odd result: trans@logisys:courtier$ irb irb(main):001:0> require 'yaml' irb(main):002:0> puts $LOADED_FEATURES.join("\n") enumerator.so /home/trans/.local/lib/ry/rubies/1.9.3-p125/lib/ruby/1.9.1/x86_64-linux/enc/encdb.so /home/trans/.local/lib/ry/rubies/1.9.3-p125/lib/ruby/1.9.1/x86_64-linux/enc/trans/transdb.so /home/trans/.local/lib/ry/rubies/1.9.3-p125/lib/ruby/1.9.1/rubygems/defaults.rb ... irb(main):003:0> y $LOADED_FEATURES --- - enumerator.so - !binary |- L2hvbWUvdHJhbnMvLmxvY2FsL2xpYi9yeS9ydWJpZXMvMS45LjMtcDEyNS9s aWIvcnVieS8xLjkuMS94ODZfNjQtbGludXgvZW5jL2VuY2RiLnNv - /home/trans/.local/lib/ry/rubies/1.9.3-p125/lib/ruby/1.9.1/x86_64-linux/enc/trans/transdb.so - /home/trans/.local/lib/ry/rubies/1.9.3-p125/lib/ruby/1.9.1/rubygems/defaults.rb ... =end -- http://bugs.ruby-lang.org/