Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the DateTime CPAN distribution.

Report information
The Basics
Id: 62314
Status: resolved
Priority: 0/
Queue: DateTime

People
Owner: Nobody in particular
Requestors: reiner.rusch [...] idealo.de
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Fwd: DateTime
Date: Wed, 20 Oct 2010 15:57:54 +0200
To: bug-datetime [...] rt.cpan.org
From: Reiner Rusch <reiner.rusch [...] idealo.de>
Hello, perhaps a bug? Best regards, Reiner Rusch
Subject: DateTime
Date: Wed, 20 Oct 2010 12:24:11 +0200
To: autarch [...] urth.org
From: Reiner Rusch <reiner.rusch [...] idealo.de>
Hello Mr. Rolsky, I had some trouble with DateTime a view days ago. Doing something like $dt = DateTime->from_epoch(epoch => int($unixTime)); Other functions/scripts outsite this function sometimes breaked with something like ############################# Use of uninitialized value in string at /usr/angebote/perlroot/lib/site_perl/5.8.6/x86_64-linux/DateTime.pm line 1833, <GEN5> line 667. ############################# By know I don't know exactly, which data curses this. But I made a workaround in DateTime.pm (above line 1833): old: ############################# sub _string_equals_overload { my ( $class, $dt1, $dt2 ) = ref $_[0] ? ( undef, @_ ) : @_; if ( !DateTime::Helpers::can( $dt2, 'utc_rd_values' ) ) { return "$dt1" eq "$dt2"; } $class ||= ref $dt1; return !$class->compare( $dt1, $dt2 ); } ############################# new: ############################# sub _string_equals_overload { my ( $class, $dt1, $dt2 ) = ref $_[0] ? ( undef, @_ ) : @_; if ( !DateTime::Helpers::can( $dt2, 'utc_rd_values' ) ) { # Hack/Workaround by R.Rusch, 19.10.2010 if (not defined $dt1) { $dt1 = ''; } if (not defined $dt2) { $dt2 = ''; } # Hack/Workaround by R.Rusch, 19.10.2010 return "$dt1" eq "$dt2"; } $class ||= ref $dt1; return !$class->compare( $dt1, $dt2 ); } ############################# Best regards from Berlin, R.Rusch
On Wed Oct 20 09:58:07 2010, reiner.rusch@idealo.de wrote: Show quoted text
> Hello, > > perhaps a bug?
Can you provide code to reproduce the error?
Subject: Re: [rt.cpan.org #62314] Use of uninitialized value in string
Date: Wed, 20 Oct 2010 16:19:45 +0200
To: bug-DateTime [...] rt.cpan.org
From: Reiner Rusch <reiner.rusch [...] idealo.de>
On Wednesday 20 October 2010 16:09:11 Dave Rolsky via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=62314 > > > On Wed Oct 20 09:58:07 2010, reiner.rusch@idealo.de wrote:
> > Hello, > > > > perhaps a bug?
> > Can you provide code to reproduce the error?
Didn't you get the old message as an attachment? I did something like that in subfunctions like this: ... if ($dataType eq "unixTimeAsDateTime") { my $dt; if ($value) { if ($value == int($value) && $value > 0) { $dt = DateTime->from_epoch(epoch => int($value)); } else { return $dt; } return $dt; } else { return $dt; } } ... if ($dataType eq "dateStringAsDateTime") { my $dt; if ($value) { my $unixTime = agentFunc::getUnixTime($value); if ($unixTime == int($unixTime) && $unixTime > 0) { $dt = DateTime->from_epoch(epoch => int($unixTime)); } else { return $dt; } return $dt; } else { return $dt; } } ... which causes sometimes a cronmail like this: ############################# Use of uninitialized value in string at /usr/angebote/perlroot/lib/site_perl/5.8.6/x86_64-linux/DateTime.pm line 1833, <GEN5> line 667. ############################# As I said it's hard to reproduce! We're working on a very large system where a lot of scripts use our central modul and so even DateTime.pm - by now I didn't find the real thing/data, which caused the problem. What I know is: The problem is not exactly in the code above, it's anywhere else where something want to use the object. Regards, Reiner
Subject: Re: [rt.cpan.org #62314] Use of uninitialized value in string
Date: Wed, 20 Oct 2010 09:42:50 -0500 (CDT)
To: Reiner Rusch via RT <bug-DateTime [...] rt.cpan.org>
From: Dave Rolsky <autarch [...] urth.org>
On Wed, 20 Oct 2010, Reiner Rusch via RT wrote: Show quoted text
> As I said it's hard to reproduce! > We're working on a very large system where a lot of scripts use our central > modul and so even DateTime.pm - by now I didn't find the real thing/data, > which caused the problem. > What I know is: The problem is not exactly in the code above, it's anywhere > else where something want to use the object.
Well, based on the code above, it looks like sometimes you're returning an undef instead of a DateTime object. Then you try to compare the undef to a DateTime and you get an uninit warning. That seems like a legitimate warning to me! -dave /*============================================================ http://VegGuide.org http://blog.urth.org Your guide to all that's veg House Absolute(ly Pointless) ============================================================*/
Subject: Re: [rt.cpan.org #62314] Use of uninitialized value in string
Date: Wed, 20 Oct 2010 16:48:04 +0200
To: bug-DateTime [...] rt.cpan.org
From: Reiner Rusch <reiner.rusch [...] idealo.de>
On Wednesday 20 October 2010 16:43:00 autarch@urth.org via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=62314 > > > On Wed, 20 Oct 2010, Reiner Rusch via RT wrote:
> > As I said it's hard to reproduce! > > We're working on a very large system where a lot of scripts use our > > central modul and so even DateTime.pm - by now I didn't find the real > > thing/data, which caused the problem. > > What I know is: The problem is not exactly in the code above, it's > > anywhere else where something want to use the object.
> > Well, based on the code above, it looks like sometimes you're returning an > undef instead of a DateTime object. Then you try to compare the undef to a > DateTime and you get an uninit warning. > > That seems like a legitimate warning to me!
Hmm, I don't think so. The code I tried was even like this: ################################# my $dt = DateTime->now(); if (...) { # calculate the DateTime of a given unix timestamp ..... return $dt; } else { # was no unix timestamp return $dt; } ################################# So, $dt was always in the right object format even the given unix timestamp was wrong. And then I got also a cronmail with the message.
Subject: Re: [rt.cpan.org #62314] Use of uninitialized value in string
Date: Thu, 21 Oct 2010 08:59:03 -0500 (CDT)
To: Reiner Rusch via RT <bug-DateTime [...] rt.cpan.org>
From: Dave Rolsky <autarch [...] urth.org>
On Wed, 20 Oct 2010, Reiner Rusch via RT wrote: Show quoted text
>> That seems like a legitimate warning to me!
> > > Hmm, I don't think so. > > The code I tried was even like this: > ################################# > my $dt = DateTime->now(); > > if (...) { > > # calculate the DateTime of a given unix timestamp > ..... > return $dt; > > } else { > # was no unix timestamp > return $dt; > } > ################################# > > So, $dt was always in the right object format even the given unix timestamp > was wrong. And then I got also a cronmail with the message.
If you're comparing a DateTime object to an undef, you'd get this warning. autarch@houseabsolute:~$ perl -MDateTime -E 'say DateTime->now eq undef' Use of uninitialized value $dt2 in string at /usr/local/lib/perl/5.10.1/DateTime.pm line 1834. The only thing I could improve is to catch this myself and use Carp to make the warning show up at the caller's location. Suppressing the warning entirely is wrong. -dave /*============================================================ http://VegGuide.org http://blog.urth.org Your guide to all that's veg House Absolute(ly Pointless) ============================================================*/
Subject: Re: [rt.cpan.org #62314] Use of uninitialized value in string
Date: Thu, 21 Oct 2010 16:03:00 +0200
To: bug-DateTime [...] rt.cpan.org
From: Reiner Rusch <reiner.rusch [...] idealo.de>
Hi Dave, I think you're right! In my case the code was perhaps ok, because by now I wasn't able to locate, where or which data curses the problem. Thank you very much! Reiner On Thursday 21 October 2010 15:59:14 autarch@urth.org via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=62314 > > > On Wed, 20 Oct 2010, Reiner Rusch via RT wrote:
> >> That seems like a legitimate warning to me!
> > > > Hmm, I don't think so. > > > > The code I tried was even like this: > > ################################# > > my $dt = DateTime->now(); > > > > if (...) { > > > > # calculate the DateTime of a given unix timestamp > > ..... > > return $dt; > > > > } else { > > # was no unix timestamp > > return $dt; > > } > > ################################# > > > > So, $dt was always in the right object format even the given unix > > timestamp was wrong. And then I got also a cronmail with the message.
> > If you're comparing a DateTime object to an undef, you'd get this warning. > > autarch@houseabsolute:~$ perl -MDateTime -E 'say DateTime->now eq undef' > Use of uninitialized value $dt2 in string at > /usr/local/lib/perl/5.10.1/DateTime.pm line 1834. > > The only thing I could improve is to catch this myself and use Carp to > make the warning show up at the caller's location. Suppressing the warning > entirely is wrong. > > > -dave > > /*============================================================ > http://VegGuide.org http://blog.urth.org > Your guide to all that's veg House Absolute(ly Pointless) > ============================================================*/
-- Mit freundlichen Grüßen Reiner Rusch Idealo Internet GmbH Zionskirchstr. 73, 10119 Berlin Geschäftsführer Martin Sinner, Dr. Albrecht v. Sonntag HRB 76749 - Amtsgericht Berlin-Charlottenburg USt.-ID: DE 813070905 www.idealo.de | www.idealo.at | www.idealo.co.uk eMail: reiner.rusch@idealo.de