[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:
@@ -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"
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user