@@ -713,7 +713,7 @@ def sendMessage(url, pilotUUID, wnVO, method, rawMessage):
713713 context .load_cert_chain (os .path .join (cert , "hostcert.pem" ), os .path .join (cert , "hostkey.pem" ))
714714 raw_data = {"method" : method , "args" : message , "extraCredentials" : '"hosts"' }
715715
716- if sys .version_info [ 0 ] == 3 :
716+ if sys .version_info . major == 3 :
717717 data = urlencode (raw_data ).encode ("utf-8" ) # encode to bytes ! for python3
718718 else :
719719 # Python2
@@ -787,19 +787,17 @@ def executeAndGetOutput(self, cmd, environDict=None):
787787 if not outChunk :
788788 continue
789789 dataWasRead = True
790- # Ensure outChunk is unicode in Python 2
791- if sys . version_info [ 0 ] < 3 :
790+ if sys . version_info . major == 2 :
791+ # Ensure outChunk is unicode in Python 2
792792 if isinstance (outChunk , str ):
793793 outChunk = outChunk .decode ("utf-8" )
794- # Strip unicode replacement characters
795- outChunk = str (outChunk .replace ("\ufffd " , "" ))
796-
797- # Ensure correct type conversion in Python 2
798- if sys .version_info [0 ] < 3 :
794+ # Strip unicode replacement characters
795+ # Ensure correct type conversion in Python 2
796+ outChunk = str (outChunk .replace (u"\ufffd " , "" ))
799797 # Avoid potential str() issues in Py2
800798 outChunk = unicode (outChunk ) # pylint: disable=undefined-variable
801799 else :
802- outChunk = str (outChunk ) # Python 3: Ensure it's a string
800+ outChunk = str (outChunk . replace ( " \ufffd " , "" ) ) # Python 3: Ensure it's a string
803801
804802 if stream == _p .stderr :
805803 sys .stderr .write (outChunk )
0 commit comments