[entropy.client.misc, entropy.output] fixes for Python 3

ConfigurationFiles._load_maybe_add (equo.client.misc): path is in bytes here

_std_write (entropy.output): fixes crash in equo conf update with "Replace
original with update" when there is an error in which case msg can be bytes:

  File ".../entropy/lib/entropy/tools.py", line 687, in movefile
    print_generic("!!! Failed to move", src, "to", dest)
  File ".../entropy/lib/entropy/output.py", line 596, in print_generic
    _std_write(msg, stderr = stderr)
  File ".../entropy/lib/entropy/output.py", line 493, in _std_write
    obj.write(msg)
This commit is contained in:
Sławomir Nizio
2019-12-13 21:06:23 +01:00
parent 2aa2c69e2b
commit bad4b21f1a
2 changed files with 8 additions and 1 deletions

View File

@@ -251,7 +251,8 @@ class ConfigurationFiles(dict):
self._entropy.output(
darkred("%s: %s") % (
_("Automerging file"),
darkgreen(filepath),
darkgreen(
self._unicode_path(filepath)),
),
importance = 0,
level = "info"

View File

@@ -489,6 +489,12 @@ def _std_write(msg, stderr = False):
if stderr:
obj = sys.stderr
if const_is_python3() and not const_isunicode(msg):
obj.flush()
obj.buffer.write(msg)
obj.flush()
return
try:
obj.write(msg)
except UnicodeEncodeError: