clogger RubyGem user+dev discussion/patches/pulls/bugs/help
 help / Atom feed
* Ruby 1.9.2 (and 1.9.1) bug (doesn't affect 1.9.3)
@ 2012-06-08 22:47 Eric Wong
  0 siblings, 0 replies; 1+ messages in thread
From: Eric Wong @ 2012-06-08 22:47 UTC (permalink / raw)
  To: clogger

I've just pushed this out to master of git://bogomips.org/clogger

Now can somebody find the commit in Ruby 1.9.3 that fixes this issue?
And perhaps file a backport ticket in case there's another 1.9.2
release.

Also, I'd appreciate a patch to replace rb_block_call() with
rb_iterate(), but needs to work under 1.8.7, 1.9.{2,3} and Rubinius.

(I unfortunately need to support some folks on 1.8.7, still :<)

>From e1bed92891f7db5c2d24040778fe31f76d723efe Mon Sep 17 00:00:00 2001
From: Eric Wong <normalperson@yhbt.net>
Date: Fri, 8 Jun 2012 15:37:38 -0700
Subject: [PATCH] test case to simulate Rack::BodyProxy usage pattern

The use of Rack::BodyProxy#method_missing causes failures
under mainline Ruby 1.9.2 and 1.9.1, but not 1.9.3.   This
test case exists to document this (now-fixed) bug for users
stuck on older Rubies.

On a side note, our usage of rb_iterate() should be rewritten
to use rb_block_call() as rb_iterate() is deprecated in 1.9.

A Ruby 1.9.2-p290 user privately reported this issue.
---
 test/test_clogger.rb | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/test/test_clogger.rb b/test/test_clogger.rb
index 14613e0..10c587a 100644
--- a/test/test_clogger.rb
+++ b/test/test_clogger.rb
@@ -481,6 +481,26 @@ class TestClogger < Test::Unit::TestCase
     assert r.object_id != body.object_id
   end
 
+  # Rack::BodyProxy does this thing with method_missing
+  # This test fails under MRI 1.9.1 and 1.9.2, but works under 1.9.3
+  def test_each_with_external_block
+    foo = Object.new
+    foo.instance_variable_set(:@body, ["BodyProxy"])
+    def foo.method_missing(*args, &block)
+      @body.__send__(*args, &block)
+    end
+    app = lambda { |env| [302, [], foo] }
+    str = StringIO.new
+    cl = Clogger.new(app, :logger => str, :format => '$body_bytes_sent')
+    r = nil
+    assert_nothing_raised { r = cl.call(@req) }
+    body = []
+    r[2].each { |x| body << x }
+    r[2].close
+    assert_equal %w(BodyProxy), body
+    assert_equal "9\n", str.string
+  end
+
   def test_http_09_request
     str = StringIO.new
     app = lambda { |env| [302, [ %w(a) ], []] }
-- 
Eric Wong


^ permalink raw reply	[flat|nested] 1+ messages in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-08 22:47 Ruby 1.9.2 (and 1.9.1) bug (doesn't affect 1.9.3) Eric Wong

clogger RubyGem user+dev discussion/patches/pulls/bugs/help

Archives are clonable:
	git clone --mirror https://bogomips.org/clogger-public
	git clone --mirror http://ou63pmih66umazou.onion/clogger-public

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.lang.ruby.clogger
	nntp://ou63pmih66umazou.onion/inbox.comp.lang.ruby.clogger

 note: .onion URLs require Tor: https://www.torproject.org/
       or Tor2web: https://www.tor2web.org/

AGPL code for this site: git clone https://public-inbox.org/ public-inbox