B: honor the UTF-8-ness of the label in B::COP::label

Fixes #24040
This commit is contained in:
Tony Cook 2026-01-07 14:38:59 +11:00
parent 09c977ddca
commit 134605c247
3 changed files with 49 additions and 1 deletions

View File

@ -4755,6 +4755,7 @@ ext/B/Makefile.PL Compiler backend makefile writer
ext/B/O.pm Compiler front-end module (-MO=...)
ext/B/t/b.t See if B works
ext/B/t/B/success.pm Test module for ext/B/t/o.t
ext/B/t/b_uni.t See if B works with Unicode
ext/B/t/bool.t See if B works for bool
ext/B/t/concise.t See whether B::Concise works
ext/B/t/concise-xs.t See whether B::Concise recognizes XS functions

View File

@ -1037,7 +1037,15 @@ next(o)
ret = newSVpvn_flags(cPVOPo->op_pv, strlen(cPVOPo->op_pv), SVs_TEMP);
break;
case 42: /* B::COP::label */
ret = sv_2mortal(newSVpv(CopLABEL(cCOPo),0));
{
STRLEN len;
U32 flags;
const char *pv = CopLABEL_len_flags(cCOPo, &len, &flags);
ret = sv_2mortal(newSVpvn(pv, len));
SvUTF8_off(ret);
if (flags & SVf_UTF8)
SvUTF8_on(ret);
}
break;
case 43: /* B::COP::arybase */
ret = sv_2mortal(newSVuv(0));

39
ext/B/t/b_uni.t Normal file
View File

@ -0,0 +1,39 @@
#!./perl
BEGIN {
unshift @INC, 't';
require Config;
if (($Config::Config{'extensions'} !~ /\bB\b/) ){
print "1..0 # Skip -- Perl configured without B module\n";
exit 0;
}
}
$| = 1;
use warnings;
use strict;
use utf8;
use B;
BEGIN {
eval { require threads; threads->import; }
}
use Test::More;
sub f {
# I like pi
π:1;
}
{
# github 24040
my $f = B::svref_2object(\&f);
my $op = $f->START;
while ($op && !($op->name =~ /^(db|next)state$/ && $op->label)) {
$op = $op->next;
}
$op or die "Not found";
my $label = $op->label;
is($label, "π", "UTF8 label correctly UTF8");
}
done_testing();