summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2010-10-18 17:57:25 -0700
committerFather Chrysostomos <sprout@cpan.org>2010-10-21 05:53:03 -0700
commit640d5d412e67683edc19515df4462d7bb4739ae2 (patch)
tree86ca357f88fd61a336d9daa8bd8b03e05ab3f545
parent8eaa0acf70f47cc5d3ed085b62e8d46cbc245651 (diff)
downloadperl-640d5d412e67683edc19515df4462d7bb4739ae2.tar.gz
[perl #33752] B::Deparse fails with utf8 and our
MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit makes B::Deparse support code like ‘our $ḟōō’. Currently, an ‘our’ variable whose name is an octet sequence that does not consist of (\w|::)+ can only be a UTF8 variable name. When the pad is made to support UTF8 properly, this may need to be changed.
-rw-r--r--dist/B-Deparse/Deparse.pm8
-rw-r--r--dist/B-Deparse/t/deparse.t15
2 files changed, 19 insertions, 4 deletions
diff --git a/dist/B-Deparse/Deparse.pm b/dist/B-Deparse/Deparse.pm
index b98b1fbf92..7ea543716b 100644
--- a/dist/B-Deparse/Deparse.pm
+++ b/dist/B-Deparse/Deparse.pm
@@ -1041,9 +1041,11 @@ sub maybe_local {
and not $self->{'avoid_local'}{$$op}) {
my $our_local = ($op->private & OPpLVAL_INTRO) ? "local" : "our";
if( $our_local eq 'our' ) {
- # XXX This assertion fails code with non-ASCII identifiers,
- # like ./ext/Encode/t/jperl.t
- die "Unexpected our($text)\n" unless $text =~ /^\W(\w+::)*\w+\z/;
+ if ( $text !~ /^\W(\w+::)*\w+\z/
+ and !utf8::decode($text) || $text !~ /^\W(\w+::)*\w+\z/
+ ) {
+ die "Unexpected our($text)\n";
+ }
$text =~ s/(\w+::)+//;
}
if (want_scalar($op)) {
diff --git a/dist/B-Deparse/t/deparse.t b/dist/B-Deparse/t/deparse.t
index 0fc3b6c87e..4b94d4a00f 100644
--- a/dist/B-Deparse/t/deparse.t
+++ b/dist/B-Deparse/t/deparse.t
@@ -17,7 +17,7 @@ BEGIN {
require feature;
feature->import(':5.10');
}
-use Test::More tests => 90;
+use Test::More tests => 91;
use Config ();
use B::Deparse;
@@ -166,6 +166,19 @@ eval <<EOFCODE and test($x);
1
EOFCODE
+# [perl #33752]
+{
+ my $code = <<"EOCODE";
+{
+ our \$\x{1e1f}\x{14d}\x{14d};
+}
+EOCODE
+ my $deparsed
+ = $deparse->coderef2text(eval "sub { our \$\x{1e1f}\x{14d}\x{14d} }" );
+ s/$ \n//x for $deparsed, $code;
+ is $deparsed, $code, 'our $funny_Unicode_chars';
+}
+
__DATA__
# 2
1;