Patchwork D1478: py3: cast error message to bytes in blackbox.py

login
register
mail settings
Submitter phabricator
Date Nov. 21, 2017, 7:53 a.m.
Message ID <differential-rev-PHID-DREV-kj6s3g5rseelsqysvmig-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/25703/
State Superseded
Headers show

Comments

phabricator - Nov. 21, 2017, 7:53 a.m.
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  According to the new exceptions reporting mechanism, this is
  the #1 crasher in the test harness for Python 3.
  
  Since this exception is in an except block, we'll likely get a
  new #1 crasher after this change. But at least we won't die
  during error handling!

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1478

AFFECTED FILES
  hgext/blackbox.py

CHANGE DETAILS




To: indygreg, #hg-reviewers
Cc: mercurial-devel
phabricator - Nov. 21, 2017, 12:30 p.m.
yuja requested changes to this revision.
yuja added a comment.
This revision now requires changes to proceed.


  encoding.strtolocal() should be used here.
  IOError may contain non-ascii character on Windows.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1478

To: indygreg, #hg-reviewers, yuja
Cc: yuja, mercurial-devel

Patch

diff --git a/hgext/blackbox.py b/hgext/blackbox.py
--- a/hgext/blackbox.py
+++ b/hgext/blackbox.py
@@ -44,6 +44,7 @@ 
 from mercurial.node import hex
 
 from mercurial import (
+    pycompat,
     registrar,
     ui as uimod,
     util,
@@ -182,7 +183,7 @@ 
                     fp.write(fmt % args)
             except (IOError, OSError) as err:
                 self.debug('warning: cannot write to blackbox.log: %s\n' %
-                           err.strerror)
+                           pycompat.bytestr(err.strerror))
                 # do not restore _bbinlog intentionally to avoid failed
                 # logging again
             else: