Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #1689 (reopened enhancement)

Opened 5 years ago

Last modified 11 months ago

[PATCH] Ruby 1.9 compatibility

Reported by: bitsweat Assigned to: Jeremy Kemper <rails@bitsweat.net>
Priority: normal Milestone: 2.1
Component: Railties Version: edge
Severity: normal Keywords: ruby 1.9 yarv
Cc: chuyeow

Description

Aiming for compatibility with Ruby 1.9. The initial patch is incomplete, though nearly all tests pass.

The only substantial breakage is that 1.9 adds a to_time method that converts Time, Date, and DateTime to Time in the local timezone. We have similar methods in Active Support which convert to time in the UTC timezone. The patch overrides the Ruby 1.9 methods in favor of our own.

Attachments

yarv.patch (12.9 kB) - added by bitsweat on 07/10/05 04:56:04.
module_methods.patch (1.2 kB) - added by lifofifo on 12/10/07 02:09:26.
Backward compatibilty for Module#instance_methods, #private_instance_methods, #public_instance_methods
fix_more_as_tests.patch (2.2 kB) - added by lifofifo on 12/10/07 04:24:30.
Some more tiny fixes
file_exist.patch (20.3 kB) - added by lifofifo on 12/10/07 05:45:46.
time_zone_compat.diff (1.3 kB) - added by chuyeow on 12/10/07 06:51:00.
GMT_to_UTC.diff (0.8 kB) - added by chuyeow on 12/10/07 07:03:27.
core_ext_1.9_compat.diff (3.8 kB) - added by chuyeow on 12/11/07 02:02:07.
more_actionpack_19.patch (5.2 kB) - added by lifofifo on 12/12/07 23:04:13.
1.9_case_file_exist_compat.diff (4.8 kB) - added by chuyeow on 12/17/07 14:29:29.
switch statement compat + more File.exists? -> File.exist?
mocha_0.5.5_for_ruby1.9.diff (0.9 kB) - added by chuyeow on 12/18/07 06:01:07.
Patch for mocha 0.5.5 Ruby 1.9 compat so that mocha tests work
make_local_constants_return_strings.patch (505 bytes) - added by fcheung on 12/22/07 13:58:22.
file_upload_fixes.diff (1.9 kB) - added by fcheung on 12/24/07 13:45:42.
remove_surplus_methods_from_javscript_proxy.diff (0.6 kB) - added by fcheung on 12/24/07 17:53:17.
fix_calculations.diff (0.6 kB) - added by fcheung on 12/25/07 21:53:30.
Don't use << on ActiveSupport::OrderedHash in 1.9 since it's really a Hash
fix_expand_range_bind_variables.diff (0.7 kB) - added by fcheung on 12/25/07 22:06:06.
don't modify array while iterating over it in 1.9
fix_content_length.diff (0.7 kB) - added by max_posedon on 01/30/08 08:54:24.
Patch fix wrong header[content-length] in response.

Change History

07/10/05 04:56:04 changed by bitsweat

  • attachment yarv.patch added.

07/07/06 23:46:26 changed by bitsweat

  • milestone changed from 1.1 to 1.x.

05/29/07 05:09:22 changed by josh

  • status changed from new to closed.
  • resolution set to wontfix.
  • summary changed from [XPATCH] Ruby 1.9 compatibility to [PATCH] Ruby 1.9 compatibility.

Closing old ticket. Please reopen if you have any updates.

12/10/07 00:20:51 changed by bitsweat

  • priority changed from low to normal.
  • status changed from closed to reopened.
  • version changed from 0.13.0 to edge.
  • resolution deleted.
  • milestone changed from 1.x to 2.1.

Ignore the patch; it's been superseded by further work on trunk. Aiming for full 1.9 compatibility with Rails 2.1.

12/10/07 01:29:45 changed by chuyeow

  • cc set to chuyeow.

Yay! Just curious, how does your Ruby 1.9 setup look like? Other than installing Ruby 1.9 did you have to recompile your gems or set any environment variables? I'm getting an awful lot of Rails HEAD test failures, so just curious if I've set up something wrong.

12/10/07 01:46:04 changed by bitsweat

I've mostly worked on Active Support so far. I'm not too worried about getting the rest compatible.

The big sticking points are getting the database drivers (in C) and Mongrel working solidly on 1.9.

12/10/07 02:09:26 changed by lifofifo

  • attachment module_methods.patch added.

Backward compatibilty for Module#instance_methods, #private_instance_methods, #public_instance_methods

12/10/07 02:19:14 changed by bitsweat

I'd rather see 1.8 emulating 1.9 behavior to encourage people to level up, much like Ruby 1.6 had a 1.8 shim.

12/10/07 04:24:30 changed by lifofifo

  • attachment fix_more_as_tests.patch added.

Some more tiny fixes

12/10/07 05:12:53 changed by bitsweat

(In [8363]) Ruby 1.9 compat. References #1689 [Pratik Naik]

12/10/07 05:45:46 changed by lifofifo

  • attachment file_exist.patch added.

12/10/07 05:54:50 changed by bitsweat

(In [8365]) Ruby 1.9 compat: File.exists\? -> File.exist\? en masse. References #1689 [Pratik Naik]

12/10/07 06:51:00 changed by chuyeow

  • attachment time_zone_compat.diff added.

12/10/07 06:53:32 changed by chuyeow

Some TimeZone compat stuff to cope with Time#to_time converting to local time.

The unless time.is_a?(::Time) nonsense is so we don't convert Times to Times (and thereby getting an undesired conversion to localtime.

12/10/07 07:03:27 changed by chuyeow

  • attachment GMT_to_UTC.diff added.

12/10/07 07:04:57 changed by chuyeow

Not 1.9 ruby compat-related, but figured since I was there, adding GMT_to_UTC.diff just to replace GMT with UTC to be consistent (Ruby outputs UTC instead of GMT almost everywhere 1.8.x+?).

12/10/07 10:05:49 changed by bitsweat

(In [8369]) Ruby 1.9 compat: TimeZone avoids localtime conversion. References #1689 [Chu Yeow]

12/10/07 10:08:11 changed by bitsweat

(In [8370]) TimeZone#to_s uses UTC rather than GMT. References #1689.

12/11/07 02:02:07 changed by chuyeow

  • attachment core_ext_1.9_compat.diff added.

12/11/07 02:06:14 changed by chuyeow

Changes in core_ext_1.9_compat.diff:

- Don't define Integer#even? and Integer#odd? if 1.9. - Use 1.9's String#start_with? and String#end_with? if 1.9. I've left the original starts_with? and ends_with? since I think that reads better but deprecation could be an option. - Not related to 1.9 compat but renamed ActiveSupport::CoreExtensions::Range::DATE_FORMATS to RANGE_FORMATS.

12/11/07 02:07:44 changed by chuyeow

That last comment didn't come out properly formatted:

  • Don't define Integer#even? and Integer#odd? if 1.9.
  • Use 1.9's String#start_with? and String#end_with? if 1.9. I've left the original starts_with? and ends_with? since I think that reads better but deprecation could be an option.
  • Not related to 1.9 compat but renamed ActiveSupport::CoreExtensions::Range::DATE_FORMATS to RANGE_FORMATS.

12/11/07 11:29:09 changed by chuyeow

I created a separate ticket for DateTime and Date compat here: #10466. I thought it'd get greater visibility since I'm changing the DateTime#xmlschema (would like feedback on whether it's OK).

12/11/07 14:17:13 changed by chuyeow

One more ticket for the broken tests in duration_test and numeric_ext_test: #10468

12/11/07 16:37:07 changed by chuyeow

#10470 for working around Module#const_* changes in 1.9.

12/12/07 23:04:13 changed by lifofifo

  • attachment more_actionpack_19.patch added.

12/12/07 23:04:45 changed by lifofifo

Added a patch to make some more actionpack tests pass

12/15/07 02:39:53 changed by bitsweat

12/17/07 14:29:29 changed by chuyeow

  • attachment 1.9_case_file_exist_compat.diff added.

switch statement compat + more File.exists? -> File.exist?

12/17/07 14:30:46 changed by chuyeow

One more patch to follow up replacing the remaining File.exists? with File.exist. Also noticed a non-1.9 compatible case..when statement.

12/17/07 18:54:58 changed by bitsweat

(In [8431]) Ruby 1.9 compatibility. References #1689.

12/18/07 06:01:07 changed by chuyeow

  • attachment mocha_0.5.5_for_ruby1.9.diff added.

Patch for mocha 0.5.5 Ruby 1.9 compat so that mocha tests work

12/18/07 06:02:06 changed by chuyeow

No Rails-related, but attaching a patch based on lifofifo's suggestion that fixes 4 lines in the Mocha 0.5.5 (r167) so that mocha tests run properly in Ruby 1.9.

12/22/07 13:58:22 changed by fcheung

  • attachment make_local_constants_return_strings.patch added.

12/22/07 13:59:06 changed by fcheung

With the patch I just added and a freshly compiled ruby 1.9, all the activesupport tests now pass on my machine.

12/22/07 18:23:44 changed by bitsweat

(In [8482]) Ruby 1.9 compat: dependencies uses Module#local_constant_names. References #1689 [Frederick Cheung]

12/24/07 06:56:27 changed by chuyeow

12/24/07 13:45:42 changed by fcheung

  • attachment file_upload_fixes.diff added.

12/24/07 13:50:22 changed by fcheung

The patch I added fixed file uploads for me. The core issue is that Tempfile delegates to File (as in 1.8), but delegate has changed: in ruby 1.9 Tempfile.new('foo').is_a?(Tempfile) #=> false because is_a? and so on are also delegated to File (whereas before Tempfile was responding to the is_a?)

12/24/07 15:17:54 changed by fcheung

I've tracked down the root causes of 2 current issues, which turn out to be ruby 1.9 problems:

12/24/07 17:53:17 changed by fcheung

  • attachment remove_surplus_methods_from_javscript_proxy.diff added.

12/24/07 17:54:43 changed by fcheung

Fixed some prototype helper tests: the ruby 1.9's BasicObject is less basic than the BlankSlate 1.8 used and so equality was done using BasicObject's equality (object_ids) rather than letting JavascriptProxy make something up via method_missing.

12/25/07 00:05:39 changed by fcheung

http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/14385 has been fixed, which seems to have fixed several crashes in Html::Selector.

12/25/07 21:53:30 changed by fcheung

  • attachment fix_calculations.diff added.

Don't use << on ActiveSupport::OrderedHash in 1.9 since it's really a Hash

12/25/07 22:06:06 changed by fcheung

  • attachment fix_expand_range_bind_variables.diff added.

don't modify array while iterating over it in 1.9

12/27/07 11:17:56 changed by bitsweat

(In [8492]) Ruby 1.9 compat: file uploads. References #1689 [Frederick Cheung]

12/27/07 11:18:15 changed by bitsweat

(In [8493]) Ruby 1.9 compat: javascript proxy. References #1689 [Frederick Cheung]

12/27/07 11:18:33 changed by bitsweat

(In [8494]) Ruby 1.9 compat: calculations don't assume array implementation of ordered hash. References #1689 [Frederick Cheung]

01/25/08 03:54:13 changed by gbuesing

(In [8716]) TimeZone#to_s uses UTC rather than GMT; reapplying change that was undone in [8679]. References #1689

01/30/08 08:54:24 changed by max_posedon

  • attachment fix_content_length.diff added.

Patch fix wrong header[content-length] in response.