Project

General

Profile

Actions

Bug #6547

closed

DateTime.new does not call #initialize

Added by lmc (Luke Mcildoon) almost 12 years ago. Updated almost 12 years ago.

Status:
Rejected
Target version:
-
ruby -v:
ruby 1.9.3p194 (2012-04-20 revision 35410) [i686-linux]
Backport:
[ruby-core:45427]

Description

Classes that extend DateTime don't appear to have their "initialize" instance method called from "new".

To reproduce:
irb(main):001:0> [RUBY_VERSION,RUBY_PLATFORM]
=> ["1.9.3", "i686-linux"]
irb(main):002:0> require "date"
=> true
irb(main):003:0> class DateTimeExtension < DateTime
irb(main):004:1> def initialize(*args)
irb(main):005:2> raise "DateTimeExtension#initialize called"
irb(main):006:2> end
irb(main):007:1> end
=> nil
irb(main):008:0> DateTimeExtension.new
=> #<DateTimeExtension: -4712-01-01T00:00:00+00:00 ((0j,0s,0n),+0s,2299161j)> # no exception raised

I expected calling "DateTimeExtension.new" to raise the exception from inside "initialize".


Files

date_initialize_patch.diff (1.96 KB) date_initialize_patch.diff unified diff of changes to date_core.c lmc (Luke Mcildoon), 06/27/2012 05:25 PM
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0