Vinzenz Feenstra has uploaded a new change for review.

Change subject: agent: Use the locale module to get the preferred encoding
......................................................................

agent: Use the locale module to get the preferred encoding

The guest agent used for the string sanitization sys.stdout.encoding
which is set to None when you're running without an allocated console.
This is the case on Windows as a service. The locale module provides
the function getpreferredencoding() which returns the required value.

Resolves: BZ#962667

Change-Id: I9ff6e3c7165599f80d13115e0173eefe0e79e664
Bug-Url: https://bugzilla.redhat.com/962667
Signed-off-by: Vinzenz Feenstra <[email protected]>
---
M ovirt-guest-agent/VirtIoChannel.py
1 file changed, 2 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-guest-agent 
refs/changes/39/14739/1

diff --git a/ovirt-guest-agent/VirtIoChannel.py 
b/ovirt-guest-agent/VirtIoChannel.py
index 30782b1..2e4cf41 100644
--- a/ovirt-guest-agent/VirtIoChannel.py
+++ b/ovirt-guest-agent/VirtIoChannel.py
@@ -20,6 +20,7 @@
 import platform
 import time
 import sys
+import locale
 
 
 # avoid pep8 warnings
@@ -31,7 +32,6 @@
         import simplejson
         return simplejson
 json = import_json()
-
 
 # Set taken from http://www.w3.org/TR/xml11/#NT-RestrictedChar
 __RESTRICTED_CHARS = set(range(8 + 1)).union(
@@ -48,7 +48,7 @@
     encodings will fail this and might get characters replaced.
     """
     try:
-        str.encode(sys.stdout.encoding, 'strict')
+        str.encode(locale.getpreferredencoding(), 'strict')
     except UnicodeError:
         try:
             return str.encode('ascii', 'replace')


--
To view, visit http://gerrit.ovirt.org/14739
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9ff6e3c7165599f80d13115e0173eefe0e79e664
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-guest-agent
Gerrit-Branch: master
Gerrit-Owner: Vinzenz Feenstra <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to