Permalink
Browse files

RT 67207 - Stop doing tied on globs (sprout)

I was mistaken. It is possible to call a method on a typeglob, as in *foo->bar. So this better
patch makes tied handles work in 5.6 and skips the special handling in 5.8 and higher, as it is
unnecessary.

I added a local *@, because of the new eval{}, which rendered the existing undef
unnecessary.

I used defined tied , because the object implementing the tied could have boolean
overloading that returns false (paranoid, I know).
  • Loading branch information...
1 parent c48f2d7 commit 7eea394380a9434bd73d39d6dcf3c8aaed974876 @toddr toddr committed May 25, 2011
Showing with 8 additions and 7 deletions.
  1. +8 −7 Expat/Expat.pm
View
@@ -442,33 +442,34 @@ sub parse {
my $result = 0;
if (defined $arg) {
+ local *@;
if (ref($arg) and UNIVERSAL::isa($arg, 'IO::Handle')) {
$ioref = $arg;
- } elsif (tied($arg)) {
- my $class = ref($arg);
- no strict 'refs';
- $ioref = $arg if defined &{"${class}::TIEHANDLE"};
+ } elsif ($] < 5.008 and defined tied($arg)) {
+ require IO::Handle;
+ $ioref = $arg;
}
else {
require IO::Handle;
eval {
no strict 'refs';
$ioref = *{$arg}{IO} if defined *{$arg};
};
- undef $@;
}
}
if (defined($ioref)) {
my $delim = $self->{Stream_Delimiter};
my $prev_rs;
+ my $ioclass = ref $ioref;
+ $ioclass = "IO::Handle" if !length $ioclass;
- $prev_rs = ref($ioref)->input_record_separator("\n$delim\n")
+ $prev_rs = $ioclass->input_record_separator("\n$delim\n")
if defined($delim);
$result = ParseStream($parser, $ioref, $delim);
- ref($ioref)->input_record_separator($prev_rs)
+ $ioclass->input_record_separator($prev_rs)
if defined($delim);
} else {
$result = ParseString($parser, $arg);

0 comments on commit 7eea394

Please sign in to comment.