mg.c : revert ENV{x} = undef behaviour to be empty string, not key deletion
authorKent Fredric <kentfredric@gmail.com>
Sat, 16 Feb 2013 17:07:59 +0000 (06:07 +1300)
committerFather Chrysostomos <sprout@cpan.org>
Sun, 17 Feb 2013 21:40:36 +0000 (13:40 -0800)
pod/perldelta.pod: document reversion of ENV{foo} = undef behaviour  in delta
t/op/magic.t: add a test for ENV{foo} = undef

mg.c
pod/perldelta.pod
t/op/magic.t

diff --git a/mg.c b/mg.c
index e4711e7..6811727 100644 (file)
--- a/mg.c
+++ b/mg.c
@@ -1101,7 +1101,7 @@ Perl_magic_setenv(pTHX_ SV *sv, MAGIC *mg)
     dVAR;
     STRLEN len = 0, klen;
     const char * const key = MgPV_const(mg,klen);
-    const char *s = NULL;
+    const char *s = "";
 
     PERL_ARGS_ASSERT_MAGIC_SETENV;
 
index b50885e..c89f644 100644 (file)
@@ -53,6 +53,13 @@ XXX For a release on a stable branch, this section aspires to be:
     If any exist, they are bugs, and we request that you submit a
     report.  See L</Reporting Bugs> below.
 
+=head2 C<$ENV{foo} = undef> no longer deletes value from environ
+
+5.17.3 Introduced a change where assiging C<undef> to an C<%ENV> key was equivalent
+to C<delete $ENV{foo}>.
+
+This release reverts that change.
+
 [ List each incompatible change as a =head2 entry ]
 
 =head1 Deprecations
index 990de55..5421d01 100644 (file)
@@ -5,7 +5,7 @@ BEGIN {
     chdir 't' if -d 't';
     @INC = '../lib';
     require './test.pl';
-    plan (tests => 178);
+    plan (tests => 179);
 }
 
 # Test that defined() returns true for magic variables created on the fly,
@@ -647,9 +647,13 @@ SKIP: {
        }
 
        $ENV{__NoNeSuCh} = 'foo';
+       $ENV{__NoNeSuCh2} = 'foo';
        $0 = 'bar';
        env_is(__NoNeSuCh => 'foo', 'setting $0 does not break %ENV');
 
+       $ENV{__NoNeSuCh2} = undef;
+       env_is(__NoNeSuCh2 => '', 'setting a key as undef does not delete it');
+
        # stringify a glob
        $ENV{foo} = *TODO;
        env_is(foo => '*main::TODO', 'ENV store of stringified glob');