diff options
author | Felipe Gasper <felipe@felipegasper.com> | 2021-07-02 11:25:05 -0400 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2021-07-06 12:22:41 +0000 |
commit | 1a93d8dfa8d615bf87ff5bc034f28f47b20208a8 (patch) | |
tree | 3d71971cde039956740ce9048a22fe7e73c7fab2 | |
parent | 97cd0e0920223ebafea7507fb0fb99c26aaa534d (diff) | |
download | perl-1a93d8dfa8d615bf87ff5bc034f28f47b20208a8.tar.gz |
Only set IOKp, not IOK on $) and $(.
Issue #18955: This will prevent serializers from serializing these
variables as numbers (which loses the additional groups).
This restores behaviour from 5.16.
-rw-r--r-- | mg.c | 8 | ||||
-rw-r--r-- | t/op/groups.t | 16 |
2 files changed, 22 insertions, 2 deletions
@@ -1240,7 +1240,13 @@ Perl_magic_get(pTHX_ SV *sv, MAGIC *mg) Safefree(gary); } } - (void)SvIOK_on(sv); /* what a wonderful hack! */ + + /* + Set this to avoid warnings when the SV is used as a number. + Avoid setting the public IOK flag so that serializers will + use the PV. + */ + (void)SvIOKp_on(sv); /* what a wonderful hack! */ #endif break; case '0': diff --git a/t/op/groups.t b/t/op/groups.t index 8ffb8ad051..e80c18241d 100644 --- a/t/op/groups.t +++ b/t/op/groups.t @@ -51,8 +51,22 @@ sub Test { my %basegroup = basegroups( $pwgid, $pwgnam ); my @extracted_supplementary_groups = remove_basegroup( \ %basegroup, \ @extracted_groups ); - plan 3; + plan 4; + { + my @warnings = do { + my @w; + local $SIG{'__WARN__'} = sub { push @w, @_ }; + + use warnings; + my $v = $( + 1; + $v = $) + 1; + + @w; + }; + + is ("@warnings", "", 'Neither $( nor $) trigger warnings when used as number.' ); + } # Test: The supplementary groups in $( should match the # getgroups(2) kernal API call. |