Respect 'use bytes' in returning $! and $^E
authorKarl Williamson <public@khwilliamson.com>
Thu, 17 Oct 2013 03:25:26 +0000 (21:25 -0600)
committerKarl Williamson <public@khwilliamson.com>
Wed, 27 Nov 2013 04:03:40 +0000 (21:03 -0700)
This addresses some of the field problems caused by commit
1500bd919ffeae0f3252f8d1bb28b03b043d328e, but by no means all.
If the stringification of $^E or $! is done in the scope of 'use bytes',
the UTF-8 flag on the result is now never set.  In such scope, the
behavior is then the same as it was prior to that commit.  The actual
behavior will change before v5.20 ships.

mg.c

diff --git a/mg.c b/mg.c
index 7203547..a4a5eec 100644 (file)
--- a/mg.c
+++ b/mg.c
@@ -762,7 +762,8 @@ S_fixup_errno_string(pTHX_ SV* sv)
      * potential that we will get it wrong however, especially on short
      * error message text.  (If it turns out to be necessary, we could
      * also keep track if the current LC_MESSAGES locale is UTF-8) */
-    if (! is_ascii_string((U8*) SvPVX_const(sv), SvCUR(sv))
+    if (! IN_BYTES  /* respect 'use bytes' */
+        && ! is_ascii_string((U8*) SvPVX_const(sv), SvCUR(sv))
         && is_utf8_string((U8*) SvPVX_const(sv), SvCUR(sv)))
     {
         SvUTF8_on(sv);