Skip Menu |

This queue is for tickets about the MooseX-Types-DateTimeX CPAN distribution.

Report information
The Basics
Id: 86174
Status: new
Priority: 0/
Queue: MooseX-Types-DateTimeX

People
Owner: Nobody in particular
Requestors: KENTNL [...] cpan.org
Cc:
AdminCc:

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



Subject: Tests fail if DateTime::Format::DateManip installed

This looks like the other Mac Bug, but its repeatable, on many OSes.

1. First, install an old copy of DateManip :

cpanm SBECK/Date-Manip-5.56.tar.gz

2. Second, install DateTime::Format::DateManip  ( which requires a v5 DateManip and WILL NOT WORK with DateManip 6 )


PERL_DL_NONLAZY=1 /home/kent/perl5/perlbrew/perls/perl-5.18.0/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'inc', 'blib/lib', 'blib/arch')" t/01_basic.t
t/01_basic.t .. 1/28
#   Failed test 'use MooseX::Types::DateTimeX;'
#   at t/01_basic.t line 14.
#     Tried to use 'MooseX::Types::DateTimeX'.
#     Error:  Bareword "MooseX::Types::DateTime::ButMaintained::DateTime" not allowed while "strict subs" in use at /home/kent/.cpanm/work/1371334251.664474/MooseX-Types-DateTimeX-0.10/blib/lib/MooseX/Types/DateTimeX.pm line 18.
# Bareword "MooseX::Types::DateTime::ButMaintained::Duration" not allowed while "strict subs" in use at /home/kent/.cpanm/work/1371334251.664474/MooseX-Types-DateTimeX-0.10/blib/lib/MooseX/Types/DateTimeX.pm line 24.
# Compilation failed in require at (eval 36) line 2.
# BEGIN failed--compilation aborted at (eval 36) line 2.
Attempt to reload MooseX/Types/DateTimeX.pm aborted.
Compilation failed in require at t/01_basic.t line 40.
BEGIN failed--compilation aborted at t/01_basic.t line 40.
# Looks like you planned 28 tests but ran 1.
# Looks like you failed 1 test of 1 run.
# Looks like your test exited with 255 just after 1.
t/01_basic.t .. Dubious, test returned 255 (wstat 65280, 0xff00)

The problem seems to be that :

>    as MooseX::Types::DateTime::ButMaintained::DateTime;

is invalid, as is

 >  as MooseX::Types::DateTime::ButMaintained::Duration;

Simply quoting these package namespaces remedies the problem, and makes the test pass.

Were there a repository in the release metadata, I would have submitted a patch.

Additonally, you may wish to recode the tests to not use DateTime::Format::DateManip, as that dependency is far less maintained than MooseX::Types::DateTime , in essence, making DateTimeX inherently less maintained than DateTime

 

I'm not going to get political about it, we just have things in Gentoo that depend on DateTimeX, and as long as that is true, I'll try to fix bugs in it =).

 

Actually, here's the patch anyway. Going to patch this downstream too because the fix is trivial enough.
Subject: DateTimeX.patch
--- lib/MooseX/Types/DateTimeX.pm 2010-09-21 15:51:35.000000000 +0000 +++ lib/MooseX/Types/DateTimeX.pm 2013-06-15 22:22:50.682619575 +0000 @@ -15,13 +15,13 @@ use MooseX::Types -declare => [qw( DateTime Duration)]; -subtype DateTime, as MooseX::Types::DateTime::ButMaintained::DateTime; +subtype DateTime, as 'MooseX::Types::DateTime::ButMaintained::DateTime'; coerce( DateTime, @{ $MooseX::Types::DateTime::ButMaintained::coercions{DateTime} }, from Str, via { DateTimeX::Easy->new($_) }, ); -subtype Duration, as MooseX::Types::DateTime::ButMaintained::Duration; +subtype Duration, as 'MooseX::Types::DateTime::ButMaintained::Duration'; coerce( Duration, @{ $MooseX::Types::DateTime::ButMaintained::coercions{"DateTime::Duration"} }, from Str, via {
On 2013-06-16 10:25:01, KENTNL wrote:
Show quoted text
> Actually, here's the patch anyway. Going to patch this downstream too
> because
> the fix is trivial enough.


Ok, on a second glance, this is bug 73467 again. But I finally understand why it doesn't work.

The problem is not that 'namespace::autoclean' is in DateTimeX , but namespace::autoclean is in ::ButMaintained, so the symbols you're referring to literally ( which are subs ) have been cleaned out of ::ButMaintained , so you can no longer refer to them.

The only way you can refer to symbols exported by a MooseX::Types library *with* namespace::autoclean in it, is by exporting those symbols into your namespace.

But you obviously can't do that with DateTimeX, because the symbols would conflict with the symbols you're trying to define.

Solution: Remove namespace::autoclean from ::ButMaintained, and make sure any namespace clensing occurs *BEFORE* you call MooseX::Types -declare

Tested that locally, and that also appears to solve this bug for me.
Looking at my comment in #73467, it appears I understood this then too, just somehow I miscommunicated what needed fixing, and you may have fixed the wrong code as a result :/

My bad.

I'm not even sure the code I'm looking at does what you think it does.

However, my string based solution will still work because of this:

https://metacpan.org/module/MooseX::Types#Uniqueness

So while a symbol may be gone, the type itself still exists. 

and the symbol only returns the fully qualified name anyway, literally, doing

>  , as Foo::Bar::Baz  

calls

>  as(Foo::Bar::Baz())

which amounts to

> as('Foo::Bar::Baz')


Proof:

Using the exported symbol

perl -MMooseX::Types::DateTime::ButMaintained=DateTime -E 'say DateTime'
MooseX::Types::DateTime::ButMaintained::DateTime

^^

Attempting to use the symbol directly ( impossible, its been cleaned )


> perl -MMooseX::Types::DateTime::ButMaintained=DateTime -E 'use strict; use warnings; say MooseX::Types::DateTime::ButMaintained::DateTime'
Name "MooseX::Types::DateTime::ButMaintained::DateTime" used only once: possible typo at -e line 1.
say() on unopened filehandle DateTime at -e line 1.


Attempting to use the symbol directly with ns::ac removed:

> perl -MMooseX::Types::DateTime::ButMaintained=DateTime -E 'use strict; use warnings; say MooseX::Types::DateTime::ButMaintained::DateTime'
MooseX::Types::DateTime::ButMaintained::DateTime