From 617c86741a3f3f6b8b03b8b4634e3a42f2a28123 Mon Sep 17 00:00:00 2001 From: "brian m. carlson" Date: Sun, 9 Dec 2012 14:19:51 +0000 Subject: [PATCH] Fix uses of UNIVERSAL->import. This patch removes all use statements for UNIVERSAL and changes the code to use the method call syntax instead, using eval where necessary. --- lib/XML/Doctype/ElementDecl.pm | 1 - lib/XML/ValidWriter.pm | 7 +++---- t/auto.t | 3 +-- t/cm_re.t | 3 +-- t/dtd.t | 1 - t/escape.t | 1 - t/foo.t | 1 - t/valid.t | 3 +-- 8 files changed, 6 insertions(+), 14 deletions(-) diff --git a/lib/XML/Doctype/ElementDecl.pm b/lib/XML/Doctype/ElementDecl.pm index 40da600..1777b53 100755 --- a/lib/XML/Doctype/ElementDecl.pm +++ b/lib/XML/Doctype/ElementDecl.pm @@ -39,7 +39,6 @@ use fields ( ) ; use Carp ; -use UNIVERSAL qw( isa ) ; $VERSION = 0.1 ; diff --git a/lib/XML/ValidWriter.pm b/lib/XML/ValidWriter.pm index 9c671fc..0c839a6 100755 --- a/lib/XML/ValidWriter.pm +++ b/lib/XML/ValidWriter.pm @@ -265,7 +265,6 @@ use fields ( 'WAS_END_TAG', # Set if last thing emitted was an empty tag or an end tag 'STRAGGLERS', # '>' if we just emitted a start tag, ']]>' if isa( 'XML::ValidWriter' ) } ) ; my $callpkg = caller(1) ; croak "No default XML::ValidWriter declared for package '$callpkg'" unless $pkg_writers{$callpkg} ; @@ -433,7 +432,7 @@ sub new { ## Find the original caller my $caller_depth = 1 ; ++$caller_depth - while caller && isa( scalar( caller $caller_depth ), __PACKAGE__ ) ; + while caller && eval { scalar( caller $caller_depth )->isa( __PACKAGE__ ) } ; $self->{CREATED_AT} = join( ', ', (caller( $caller_depth ))[1,2] ); $self->reset ; @@ -1535,7 +1534,7 @@ use vars qw( $AUTOLOAD ) ; sub AUTOLOAD { croak "Function $AUTOLOAD not AUTOLOADable (no functions are)" - unless isa( $_[0], __PACKAGE__ ) ; + unless eval { $_[0]->isa( __PACKAGE__ ) }; my XML::ValidWriter $self = $_[0] ; unless ( exists $self->{METHODS}->{$AUTOLOAD} ) { diff --git a/t/auto.t b/t/auto.t index 61d6fe3..14255a7 100755 --- a/t/auto.t +++ b/t/auto.t @@ -15,7 +15,6 @@ use strict ; use IO::File; use Test ; use XML::Doctype ; -use UNIVERSAL qw( isa ) ; my $w ; my $doctype ; @@ -324,7 +323,7 @@ TOHERE ## sub { $w = XML::AutoWriter->new() ; - ok( isa( $w, "XML::AutoWriter" ) ) ; + ok( eval { $w->isa( "XML::AutoWriter" ) } ) ; }, ) ; diff --git a/t/cm_re.t b/t/cm_re.t index ed840b4..5e7d59b 100755 --- a/t/cm_re.t +++ b/t/cm_re.t @@ -14,7 +14,6 @@ package main ; use strict ; use Test ; use XML::Doctype ; -use UNIVERSAL qw( isa ) ; my $dt ; my $re ; @@ -28,7 +27,7 @@ sub { TOHERE - ok( isa( $dt, 'XML::Doctype' ) ) ; + ok( eval { $dt->isa( 'XML::Doctype' ) } ) ; }, sub { ok( eval { qr/^$dt->{ELTS}->{b}->{CONTENT}$/ } ) }, diff --git a/t/dtd.t b/t/dtd.t index 9143aae..eb09a91 100755 --- a/t/dtd.t +++ b/t/dtd.t @@ -8,7 +8,6 @@ dtd.t - test suite for XML::Doctype use strict ; use Test ; -use UNIVERSAL qw( isa ) ; use XML::Doctype; diff --git a/t/escape.t b/t/escape.t index 9c8feef..941a8b1 100755 --- a/t/escape.t +++ b/t/escape.t @@ -14,7 +14,6 @@ package main ; use strict ; use Test ; use XML::Doctype ; -use UNIVERSAL qw( isa ) ; my $w ; my $doctype ; diff --git a/t/foo.t b/t/foo.t index 474cdf7..75e1a99 100755 --- a/t/foo.t +++ b/t/foo.t @@ -14,7 +14,6 @@ package main ; use strict ; use Test ; use XML::Doctype ; -use UNIVERSAL qw( isa ) ; my $w ; my $doctype ; diff --git a/t/valid.t b/t/valid.t index d917a78..2138be0 100755 --- a/t/valid.t +++ b/t/valid.t @@ -14,7 +14,6 @@ package main ; use strict ; use Test ; use XML::Doctype ; -use UNIVERSAL qw( isa ) ; use IO::File; my $w ; @@ -296,7 +295,7 @@ sub { ## sub { $w = XML::ValidWriter->new() ; - ok( isa( $w, "XML::ValidWriter" ) ) ; + ok( eval { $w->isa( "XML::ValidWriter" ) } ) ; }, ) ; -- 1.8.0