This commit is contained in:
Miroslav Stampar 2011-04-19 22:33:03 +00:00
parent 9a9838f1e6
commit de2479b864

View File

@ -604,6 +604,21 @@ def dataToStdout(data, forceOutput=False):
if not ('threadException' in kb and kb.threadException): if not ('threadException' in kb and kb.threadException):
if forceOutput or not getCurrentThreadData().disableStdOut: if forceOutput or not getCurrentThreadData().disableStdOut:
try: try:
if IS_WIN:
output = data.encode('ascii', errors="replace")
if output != data and 'dataToStdout' not in kb.warningFlags:
kb.warningFlags.add('dataToStdout')
warnMsg = "cannot properly display Unicode characters "
warnMsg += "inside Windows OS command prompt "
warnMsg += "(http://bugs.python.org/issue1602). all "
warnMsg += "similar occurances will result in "
warnMsg += "replacement with '?' character. please, find "
warnMsg += "proper character representations inside "
warnMsg += "coresponding output files. "
warnMsg += "p.s. FORMAT C: /U is highly recommended"
logger.critical(warnMsg)
sys.stdout.write(output)
else:
sys.stdout.write(data.encode(sys.stdout.encoding)) sys.stdout.write(data.encode(sys.stdout.encoding))
except: except:
sys.stdout.write(data.encode(UNICODE_ENCODING)) sys.stdout.write(data.encode(UNICODE_ENCODING))