summaryrefslogtreecommitdiff
path: root/lib/base.pm
diff options
context:
space:
mode:
authornothingmuch@woobling.org <nothingmuch@woobling.org>2004-01-18 15:15:46 +0000
committerDave Mitchell <davem@fdisolutions.com>2004-01-24 16:13:17 +0000
commit8731c5d9eb453a5b2d087dabd7a5f51b576b8048 (patch)
tree2e9f87e2d418447d00a68eeef07b666ff7383796 /lib/base.pm
parent6eb87ff8bf4b0fb28bd1498a03b1502cf11429d2 (diff)
downloadperl-8731c5d9eb453a5b2d087dabd7a5f51b576b8048.tar.gz
[perl #24942] fields::inherit doesn't bless derived
package's \%FIELDS, results in phash deprecation errors. From: "nothingmuch@woobling.org (via RT)" <perlbug-followup@perl.org> Message-Id: <rt-3.0.8-24942-70144.16.7177902690315@perl.org> p4raw-id: //depot/perl@22208
Diffstat (limited to 'lib/base.pm')
-rw-r--r--lib/base.pm25
1 files changed, 20 insertions, 5 deletions
diff --git a/lib/base.pm b/lib/base.pm
index 04a8aa961e..b735848f9b 100644
--- a/lib/base.pm
+++ b/lib/base.pm
@@ -38,11 +38,26 @@ sub get_attr {
return $Fattr->{$_[0]};
}
-sub get_fields {
- # Shut up a possible typo warning.
- () = \%{$_[0].'::FIELDS'};
-
- return \%{$_[0].'::FIELDS'};
+if ($] < 5.009) {
+ *get_fields = sub {
+ # Shut up a possible typo warning.
+ () = \%{$_[0].'::FIELDS'};
+ my $f = \%{$_[0].'::FIELDS'};
+
+ # should be centralized in fields? perhaps
+ # fields::mk_FIELDS_be_OK. Peh. As long as %{ $package . '::FIELDS' }
+ # is used here anyway, it doesn't matter.
+ bless $f, 'pseudohash' if (ref($f) ne 'pseudohash');
+
+ return $f;
+ }
+}
+else {
+ *get_fields = sub {
+ # Shut up a possible typo warning.
+ () = \%{$_[0].'::FIELDS'};
+ return \%{$_[0].'::FIELDS'};
+ }
}
sub import {