From: "bugmenot123 (DoNot BugMe)" Date: 2013-09-23T19:05:18+09:00 Subject: [ruby-core:57320] [ruby-trunk - Bug #8935] Zlib::GzipWriter.new with block truncates output to 20 corrupted bytes Issue #8935 has been updated by bugmenot123 (DoNot BugMe). Whoa. Has that always been the case? Cause I'm pretty sure I saw this code used somewhere else too. The problem with .open, which definitely takes a block, is that it only works with file names, not IO objects and thus not StringIO. But it's not unreasonable to want to transform a string to a gzipped string, right? ---------------------------------------- Bug #8935: Zlib::GzipWriter.new with block truncates output to 20 corrupted bytes https://bugs.ruby-lang.org/issues/8935#change-41928 Author: bugmenot123 (DoNot BugMe) Status: Open Priority: Normal Assignee: Category: Target version: ruby -v: ruby 2.0.0p247 (2013-06-27 revision 41674) [i686-linux] Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN =begin (({Zlib::GzipWriter.new})) with block truncates output to 20 corrupted bytes. #!/usr/bin/ruby -w require "zlib" require "stringio" input = File.read "/dev/urandom", 200 corrupted and only 20 bytes long: out1 = Zlib::GzipWriter.new(StringIO.new){ |gz| gz.write input }.close.string puts out1.bytesize, out1.inspect, "" good: writer = Zlib::GzipWriter.new(StringIO.new) writer.write input out2 = writer.close.string puts out2.bytesize, out2.inspect =end -- http://bugs.ruby-lang.org/