Re: patch to DT::F::Builder
That bit sets @Carp::CARP_NOT. In your code you should be setting @Your::Module::CARP_NOT. It's intended to be set just once, like @ISA, not just before calling carp. Got it. I think this diff would do. Thanks for the pointer :) Index: lib/DateTime/Format/Builder.pm === RCS file: /cvsroot/perl-date-time/modules/DateTime-Format-Builder/lib/DateTime/F ormat/Builder.pm,v retrieving revision 1.36 diff -d -u -r1.36 Builder.pm --- lib/DateTime/Format/Builder.pm 30 Jan 2004 07:09:13 - 1.36 +++ lib/DateTime/Format/Builder.pm 4 Feb 2004 09:07:14 - @@ -14,7 +14,7 @@ use Params::Validate qw( validate SCALAR ARRAYREF HASHREF SCALARREF CODEREF GLOB GLOBREF UNDEF ); -use vars qw( $VERSION %dispatch_data ); +use vars qw( $VERSION %dispatch_data @CARP_NOT ); my $parser = 'DateTime::Format::Builder::Parser'; $VERSION = '0.7801'; @@ -201,13 +201,8 @@ { my ($class, $input) = @_; -my $pkg; -my $i = 0; -while (($pkg) = caller($i++)) { -last if (!UNIVERSAL::isa($pkg, 'DateTime::Format::Builder') && -!UNIVERSAL::isa($pkg, 'DateTime::Format::Builder::Parser')); -} -local $Carp::CarpLevel = $i; +local @CARP_NOT = +qw(DateTime::Format::Builder DateTime::Format::Builder::Parser); croak "Invalid date format: $input"; }
Re: patch to DT::F::Builder
On Fri, Jan 30, 2004 at 12:18:51AM -0600, Dave Rolsky <[EMAIL PROTECTED]> wrote: > On Thu, 29 Jan 2004, Daisuke Maki wrote: > > > > Can't this be done with the @CARP_NOT variable? > > > > Hmmm, I was trying to do this: > > > >sub on_fail { > > my($class, $input) = @_; > > local @Carp::CARP_NOT = qw( PKGS ... ); > > croak $input; > >} > > > > But somehow the messages where unaltered, so now I look at Carp.pm from > > my perl 5.8.3, and I see the following: > > > >sub shortmess { # Short-circuit &longmess if called via multiple packages > > { local $@; require Carp::Heavy; } # XXX fix require to not clear [EMAIL > > PROTECTED] > > # Icky backwards compatibility wrapper. :-( > > my $call_pack = caller(); > > local @CARP_NOT = caller(); # <<< RIGHT HERE > > shortmess_heavy(@_); > >} > > > > Hmph. local @CARP_NOT = caller()? > > It's overriding @CARP_NOT regardless of what the caller has done...? > > > > Dave, mind if I just fall back to what I initially proposed? > > Sure, that's fine. Looks like Carp is a bit broken. That bit sets @Carp::CARP_NOT. In your code you should be setting @Your::Module::CARP_NOT. It's intended to be set just once, like @ISA, not just before calling carp.
Re: patch to DT::F::Builder
On Thu, Jan 29, 2004 at 04:41:41PM -0800, Daisuke Maki <[EMAIL PROTECTED]> wrote: > > It was really annoying me that parsers based on DT::F::Builder would by > default report a parse failure as being in DT::F::B::Parser. > > I'd like the error message to tell me where in the calling script it > failed, so I'd like to introduce this patch. > > Index: lib/DateTime/Format/Builder.pm > === > RCS file: > /cvsroot/perl-date-time/modules/DateTime-Format-Builder/lib/DateTime/F > ormat/Builder.pm,v > retrieving revision 1.35 > diff -d -u -r1.35 Builder.pm > --- lib/DateTime/Format/Builder.pm 26 Jan 2004 18:46:45 - 1.35 > +++ lib/DateTime/Format/Builder.pm 30 Jan 2004 00:37:34 - > @@ -200,6 +200,13 @@ > sub on_fail > { > my ($class, $input) = @_; > + > +my $i = 0; > +while (my ($pkg) = caller($i++)) { > +last if ($pkg ne 'DateTime::Format::Builder' && > +$pkg !~ /^DateTime::Format::Builder::Parser/); > +} > +local $Carp::CarpLevel = $i; > croak "Invalid date format: $input"; > } > CarpLevel is (at least semi-) deprecated. Consider using @CARP_NOT.
Re: patch to DT::F::Builder
On Thu, 29 Jan 2004, Daisuke Maki wrote: > > Can't this be done with the @CARP_NOT variable? > > Hmmm, I was trying to do this: > >sub on_fail { > my($class, $input) = @_; > local @Carp::CARP_NOT = qw( PKGS ... ); > croak $input; >} > > But somehow the messages where unaltered, so now I look at Carp.pm from > my perl 5.8.3, and I see the following: > >sub shortmess { # Short-circuit &longmess if called via multiple packages > { local $@; require Carp::Heavy; } # XXX fix require to not clear [EMAIL > PROTECTED] > # Icky backwards compatibility wrapper. :-( > my $call_pack = caller(); > local @CARP_NOT = caller(); # <<< RIGHT HERE > shortmess_heavy(@_); >} > > Hmph. local @CARP_NOT = caller()? > It's overriding @CARP_NOT regardless of what the caller has done...? > > Dave, mind if I just fall back to what I initially proposed? Sure, that's fine. Looks like Carp is a bit broken. -dave /*=== House Absolute Consulting www.houseabsolute.com ===*/
Re: patch to DT::F::Builder
Can't this be done with the @CARP_NOT variable? Hmmm, I was trying to do this: sub on_fail { my($class, $input) = @_; local @Carp::CARP_NOT = qw( PKGS ... ); croak $input; } But somehow the messages where unaltered, so now I look at Carp.pm from my perl 5.8.3, and I see the following: sub shortmess { # Short-circuit &longmess if called via multiple packages { local $@; require Carp::Heavy; } # XXX fix require to not clear [EMAIL PROTECTED] # Icky backwards compatibility wrapper. :-( my $call_pack = caller(); local @CARP_NOT = caller(); # <<< RIGHT HERE shortmess_heavy(@_); } Hmph. local @CARP_NOT = caller()? It's overriding @CARP_NOT regardless of what the caller has done...? Dave, mind if I just fall back to what I initially proposed? --d
Re: patch to DT::F::Builder
On Thu, 29 Jan 2004, Daisuke Maki wrote: > > > Can't this be done with the @CARP_NOT variable? > > Wow, how on earth have I been ignorant of this variable for such a long > time...? > > Anyway, I can write a different version, but is the idea acceptable? Yeah, the idea is good. Feel free to check the change in _with a test_ ;) -dave /*=== House Absolute Consulting www.houseabsolute.com ===*/
Re: patch to DT::F::Builder
Can't this be done with the @CARP_NOT variable? Wow, how on earth have I been ignorant of this variable for such a long time...? Anyway, I can write a different version, but is the idea acceptable? --d
Re: patch to DT::F::Builder
On Thu, 29 Jan 2004, Daisuke Maki wrote: > It was really annoying me that parsers based on DT::F::Builder would by > default report a parse failure as being in DT::F::B::Parser. > > I'd like the error message to tell me where in the calling script it > failed, so I'd like to introduce this patch. > > Index: lib/DateTime/Format/Builder.pm > === > RCS file: > /cvsroot/perl-date-time/modules/DateTime-Format-Builder/lib/DateTime/F > ormat/Builder.pm,v > retrieving revision 1.35 > diff -d -u -r1.35 Builder.pm > --- lib/DateTime/Format/Builder.pm 26 Jan 2004 18:46:45 - 1.35 > +++ lib/DateTime/Format/Builder.pm 30 Jan 2004 00:37:34 - > @@ -200,6 +200,13 @@ > sub on_fail > { > my ($class, $input) = @_; > + > +my $i = 0; > +while (my ($pkg) = caller($i++)) { > +last if ($pkg ne 'DateTime::Format::Builder' && > +$pkg !~ /^DateTime::Format::Builder::Parser/); > +} > +local $Carp::CarpLevel = $i; > croak "Invalid date format: $input"; > } Can't this be done with the @CARP_NOT variable? -dave /*=== House Absolute Consulting www.houseabsolute.com ===*/