summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSascha Blank <unknown>2007-12-07 19:47:46 -0800
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2007-12-08 23:28:41 +0000
commitb384a05d76a2022ec642d8bd7b87bb7147132641 (patch)
treeec664e0256ba8c1b5b4448dc1cba5816a3d6a4f2
parent25ff843968f41a8aa0535a62280b51007713d2eb (diff)
downloadperl-b384a05d76a2022ec642d8bd7b87bb7147132641.tar.gz
[perl #48355] Handling of RAWDATA broken badly in Attribute::Handlers in perl 5.10.0 RC2
From: Sascha Blank (via RT) <perlbug-followup@perl.org> Message-ID: <rt-3.6.HEAD-28750-1197114466-1411.48355-75-0@perl.org> p4raw-id: //depot/perl@32598
-rw-r--r--lib/Attribute/Handlers.pm11
-rw-r--r--t/op/attrhand.t27
2 files changed, 34 insertions, 4 deletions
diff --git a/lib/Attribute/Handlers.pm b/lib/Attribute/Handlers.pm
index e035a14b6f..6c7b3f5c4f 100644
--- a/lib/Attribute/Handlers.pm
+++ b/lib/Attribute/Handlers.pm
@@ -190,9 +190,14 @@ sub _apply_handler_AH_ {
my $sym = findsym($pkg, $ref);
$sym ||= $type eq 'CODE' ? 'ANON' : 'LEXICAL';
no warnings;
- my $evaled = !$raw && eval("package $pkg; no warnings; no strict;
- local \$SIG{__WARN__}=sub{die}; [$data]");
- $data = $evaled unless $@;
+ if (!$raw && defined($data)) {
+ if ($data ne '') {
+ my $evaled = eval("package $pkg; no warnings; no strict;
+ local \$SIG{__WARN__}=sub{die}; [$data]");
+ $data = $evaled unless $@;
+ }
+ else { $data = undef }
+ }
$pkg->$handler($sym,
(ref $sym eq 'GLOB' ? *{$sym}{ref $ref}||$ref : $ref),
$attr,
diff --git a/t/op/attrhand.t b/t/op/attrhand.t
index fb8069f6ce..8b11ac424b 100644
--- a/t/op/attrhand.t
+++ b/t/op/attrhand.t
@@ -6,7 +6,7 @@ BEGIN {
require './test.pl';
}
-plan tests => 1;
+plan tests => 4;
# test for bug #38475: parsing errors with multiline attributes
@@ -22,6 +22,26 @@ sub WrongAttr :ATTR(CODE,RAWDATA) {
::ok(0);
}
+sub CheckData :ATTR(RAWDATA) {
+ # check that the $data element contains the given attribute parameters.
+
+ if ($_[4] eq "12, 14") {
+ ::ok(1)
+ }
+ else {
+ ::ok(0)
+ }
+}
+
+sub CheckEmptyValue :ATTR() {
+ if (not defined $_[4]) {
+ ::ok(1)
+ }
+ else {
+ ::ok(0)
+ }
+}
+
package Deer;
use base 'Antler';
@@ -35,3 +55,8 @@ sub something : TypeCheck(
}
something();
+
+sub c :CheckData(12, 14) {};
+
+sub d1 :CheckEmptyValue() {};
+sub d2 :CheckEmptyValue {};