Unable to Patch C extension gems - What approach?

Vít Ondruch vondruch at redhat.com
Mon Feb 13 11:10:34 UTC 2012


Dne 11.2.2012 01:19, Shawn Starr napsal(a):
> On Friday, February 10, 2012 06:46:50 PM Shawn Starr wrote:
>> On Friday, February 10, 2012 09:40:39 AM Vít Ondruch wrote:
>>> Hi Shawn,
>>>
>>> Dne 10.2.2012 05:04, Shawn Starr napsal(a):
>>>> On Thursday, February 09, 2012 01:57:34 PM Shawn wrote:
>>>>> Thanks Vit, seems like a good approach to me. I'll look at your SRPM
>>>>> today
>>>>> and see what the failure is.
>>>> Hello,
>>>>
>>>> This had a cascading effect.. rubygem-idn is now fixed, tests pass,
>>>> although I have to do some force_encoding() to get the tests to work.
>>> Are you sure you applied the fixes on the correct place? It seems that
>>> method #toUnicode should really return UTF-8, so the fix should be in
>>> the method itself, not in the test. The same apply for #toASCII.
>> I can fix that and spin another build, good point.
> You are referring to rubygem-addressable?
>
> --- lib/addressable/idna/native.rb      1969-12-31 19:00:00.000000000 -0500
> +++ lib/addressable/idna/native.rb.fixed        2012-02-09 22:32:39.432905367
> -0500
> @@ -37,7 +37,7 @@ module Addressable
>       end
>
>       def self.to_unicode(value)
> -      IDN::Idna.toUnicode(value)
> +      IDN::Idna.toUnicode(value).force_encoding('UTF-8')
>       end
>     end
>   end

If you do it right in rubygem-idn, then you could remove the 
#force_encoding in rubygem-addressabe, i.e. rubygem-addressable should 
stay untouched IMO. Moreover, it is dangerous to force encoding just 
like that. In rubygem-idn, there has to be clear in what encoding is the 
string returned by the library and you have to use the #force_encoding 
for that. Later, Ruby knows encoding of the string and it should handle 
it correctly, at least correctly fail if there is some unexpected 
conversion needed.

>
> for rubygem-idn:
>
> ext/idna.c:
>
> How would i return UTF-8 within C language, do we assume always UTF-8?
> if so then something like this? I'm not familar with Ruby C APIs.
>
> static VALUE toUnicode(int argc, VALUE argv[], VALUE self) {
> ....
> ....
> ....
> - retv = rb_str_new2(buf);
> +retv = rb_funcall(buf, rb_intern("force_encoding"), 1, rb_str_new2("utf-8"));
> xfree(buf);
> return retv;
> }
>
> If that is right I wil adjust fir toUnicode and toASCII in rubygem-idn.

Nether I am expert on Ruby C APIs, however this looks good to me.


>
>
>
>
>>>> Push to f17-candidate and rawhide.
>>>>
>>>> Because rubygem-addressable (pending review) uses GNU idn directly, this
>>>> also broke with Ruby 1.9.3, I have fixed this also (see patch in SRPM).
>>> You see, the patch for addressable confirms my suspicion.
>> for addressable, yes. I will fix it in rubygem-idn to the method vs test
>> cases.
>>
>>> Vit
>>>
>>>>> From: "Vít Ondruch"<vondruch at redhat.com>
>>>>> To:
>>>>> "ruby-sig at lists.fedoraproject.org"<ruby-sig at lists.fedoraproject.org>
>>>>> Sent: February 9, 2012 8:48 AM
>>>>> Subject: Re: Unable to Patch C extension gems - What approach?
>>>>>
>>>>> Shawn,
>>>>>
>>>>> I spent some time with rubygem-idn and here [1] is the srpm I came up
>>>>> with. Unfortunately, the test suite fails, probably due to changes in
>>>>> encoding in Ruby 1.9. I would appreciate if you can continue where I
>>>>> ended and make the test suite pass.
>>>>>
>>>>> I also worked a bit on the packaging guidelines [2], and I would
>>>>> appreciate any feedback.
>>>>>
>>>>>
>>>>> Vit
>>>>>
>>>>> [1] http://vondruch.fedorapeople.org/rubygem-idn-0.0.2-4.fc18.src.rpm
>>>>> [2]
>>>>> https://fedoraproject.org/wiki/PackagingDrafts/Ruby#Binary_Extension_Fa
>>>>> il
>>>>> s_t o_Build
>>>>>
>>>>> Dne 9.2.2012 09:05, Vít Ondruch napsal(a):
>>>>>> Dne 9.2.2012 02:14, Shawn Starr napsal(a):
>>>>>>>> This is a problem that Vit has been trying to solve some time ago,
>>>>>>>> here is
>>>>>>>> the discussion with suggested steps (not optimal, but there is
>>>>>>>> probably no
>>>>>>>> better way, yet) [1].
>>>>>>> This is going be a problem. Do we have any official approach? I would
>>>>>>> rather
>>>>>>> not repackage the gem manually, this is a serious problem for me
>>>>>>> right now.
>>>>>> Actually you are the first lucky one who needs this. After rebuilding
>>>>>> most of the packages we really did not meet other gem which needs this
>>>>>> treatment. There will be no other/better way then the one described in
>>>>>> link posted by bkabrda.
>>>>>>
>>>>>> However, as we need some good example how to do it for guidelines and
>>>>>> FPC, I'll take a look at this case. Do you have already patch which
>>>>>> fixes the gem? Are you doing to use this one [1]?
>>>>>>
>>>>>> Vit
>>>>>>
>>>>>>
>>>>>>
>>>>>> [1] https://github.com/mihu/idn
>>>>>>
>>>>>> _______________________________________________
>>>>>> ruby-sig mailing list
>>>>>> ruby-sig at lists.fedoraproject.org
>>>>>> https://admin.fedoraproject.org/mailman/listinfo/ruby-sig
>>>>> _______________________________________________
>>>>> ruby-sig mailing list
>>>>> ruby-sig at lists.fedoraproject.org
>>>>> https://admin.fedoraproject.org/mailman/listinfo/ruby-sig
>>>>> _______________________________________________
>>>>> ruby-sig mailing list
>>>>> ruby-sig at lists.fedoraproject.org
>>>>> https://admin.fedoraproject.org/mailman/listinfo/ruby-sig
>>>> _______________________________________________
>>>> ruby-sig mailing list
>>>> ruby-sig at lists.fedoraproject.org
>>>> https://admin.fedoraproject.org/mailman/listinfo/ruby-sig
>>> _______________________________________________
>>> ruby-sig mailing list
>>> ruby-sig at lists.fedoraproject.org
>>> https://admin.fedoraproject.org/mailman/listinfo/ruby-sig
>> _______________________________________________
>> ruby-sig mailing list
>> ruby-sig at lists.fedoraproject.org
>> https://admin.fedoraproject.org/mailman/listinfo/ruby-sig
> _______________________________________________
> ruby-sig mailing list
> ruby-sig at lists.fedoraproject.org
> https://admin.fedoraproject.org/mailman/listinfo/ruby-sig



More information about the ruby-sig mailing list