[前][次][番号順一覧][スレッド一覧]

ruby-changes:27177

From: drbrain <ko1@a...>
Date: Thu, 14 Feb 2013 07:12:35 +0900 (JST)
Subject: [ruby-changes:27177] drbrain:r39229 (ruby_2_0_0): * Backport r39213 from trunk [ruby-trunk - Bug #7383]

drbrain	2013-02-14 07:07:59 +0900 (Thu, 14 Feb 2013)

  New Revision: 39229

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=39229

  Log:
    * Backport r39213 from trunk [ruby-trunk - Bug #7383]
    
    * lib/rubygems.rb:  Return BINARY strings from Gem.gzip and Gem.gunzip.
      Fixes intermittent test failures.  RubyGems issue #450 by Jeremey
      Kemper.
    * test/rubygems/test_gem.rb:  Test for the above.

  Modified files:
    branches/ruby_2_0_0/ChangeLog
    branches/ruby_2_0_0/lib/rubygems.rb
    branches/ruby_2_0_0/test/rubygems/test_gem.rb

Index: ruby_2_0_0/ChangeLog
===================================================================
--- ruby_2_0_0/ChangeLog	(revision 39228)
+++ ruby_2_0_0/ChangeLog	(revision 39229)
@@ -1,3 +1,12 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ChangeLog#L1
+Thu Feb 14 07:04:13 2013  Eric Hodel  <drbrain@s...>
+
+	* Backport r39213 from trunk [ruby-trunk - Bug #7383]
+
+	* lib/rubygems.rb:  Return BINARY strings from Gem.gzip and Gem.gunzip.
+	  Fixes intermittent test failures.  RubyGems issue #450 by Jeremey
+	  Kemper.
+	* test/rubygems/test_gem.rb:  Test for the above.
+
 Thu Feb 14 07:01:12 2013  Eric Hodel  <drbrain@s...>
 
 	* Backport part of r39166 from trunk [ruby-trunk - Bug #7809]
Index: ruby_2_0_0/lib/rubygems.rb
===================================================================
--- ruby_2_0_0/lib/rubygems.rb	(revision 39228)
+++ ruby_2_0_0/lib/rubygems.rb	(revision 39229)
@@ -475,7 +475,9 @@ module Gem https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/lib/rubygems.rb#L475
     require 'zlib'
     data = StringIO.new data
 
-    Zlib::GzipReader.new(data).read
+    unzipped = Zlib::GzipReader.new(data).read
+    unzipped.force_encoding Encoding::BINARY if Object.const_defined? :Encoding
+    unzipped
   end
 
   ##
@@ -486,6 +488,7 @@ module Gem https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/lib/rubygems.rb#L488
     require 'stringio'
     require 'zlib'
     zipped = StringIO.new
+    zipped.set_encoding Encoding::BINARY if Object.const_defined? :Encoding
 
     Zlib::GzipWriter.wrap zipped do |io| io.write data end
 
Index: ruby_2_0_0/test/rubygems/test_gem.rb
===================================================================
--- ruby_2_0_0/test/rubygems/test_gem.rb	(revision 39228)
+++ ruby_2_0_0/test/rubygems/test_gem.rb	(revision 39229)
@@ -1,3 +1,4 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/rubygems/test_gem.rb#L1
+# coding: US-ASCII
 require 'rubygems/test_case'
 require 'rubygems'
 require 'rubygems/installer'
@@ -1237,6 +1238,33 @@ class TestGem < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/rubygems/test_gem.rb#L1238
     end
   end
 
+  def test_self_gunzip
+    input = "\x1F\x8B\b\0\xED\xA3\x1AQ\0\x03\xCBH" +
+            "\xCD\xC9\xC9\a\0\x86\xA6\x106\x05\0\0\0"
+
+    output = Gem.gunzip input
+
+    assert_equal 'hello', output
+
+    return unless Object.const_defined? :Encoding
+
+    assert_equal Encoding::BINARY, output.encoding
+  end
+
+  def test_self_gzip
+    input = 'hello'
+
+    output = Gem.gzip input
+
+    zipped = StringIO.new output
+
+    assert_equal 'hello', Zlib::GzipReader.new(zipped).read
+
+    return unless Object.const_defined? :Encoding
+
+    assert_equal Encoding::BINARY, output.encoding
+  end
+
   if Gem.win_platform? && '1.9' > RUBY_VERSION
     # Ruby 1.9 properly handles ~ path expansion, so no need to run such tests.
     def test_self_user_home_userprofile

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]