Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 56b6bf7

Browse files
committed
Patch for an Issue #978
1 parent ab49fe6 commit 56b6bf7

3 files changed

Lines changed: 12 additions & 5 deletions

File tree

lib/core/common.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2068,7 +2068,10 @@ def getUnicode(value, encoding=None, noneToNull=False):
20682068
try:
20692069
return unicode(value, encoding or kb.get("pageEncoding") or UNICODE_ENCODING)
20702070
except UnicodeDecodeError, ex:
2071-
value = value[:ex.start] + "".join(INVALID_UNICODE_CHAR_FORMAT % ord(_) for _ in value[ex.start:ex.end]) + value[ex.end:]
2071+
try:
2072+
return unicode(value, UNICODE_ENCODING)
2073+
except:
2074+
value = value[:ex.start] + "".join(INVALID_UNICODE_CHAR_FORMAT % ord(_) for _ in value[ex.start:ex.end]) + value[ex.end:]
20722075
else:
20732076
try:
20742077
return unicode(value)

lib/core/convert.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,17 +145,21 @@ def htmlunescape(value):
145145
return retVal
146146

147147
def singleTimeWarnMessage(message): # Cross-linked function
148-
raise NotImplementedError
148+
sys.stdout.write(message)
149+
sys.stdout.write("\n")
150+
sys.stdout.flush()
149151

150152
def stdoutencode(data):
151153
retVal = None
152154

153155
try:
156+
data = data or ""
157+
154158
# Reference: http://bugs.python.org/issue1602
155159
if IS_WIN:
156-
output = data.encode("ascii", "replace")
160+
output = data.encode(sys.stdout.encoding, "replace")
157161

158-
if output != data:
162+
if '?' in output:
159163
warnMsg = "cannot properly display Unicode characters "
160164
warnMsg += "inside Windows OS command prompt "
161165
warnMsg += "(http://bugs.python.org/issue1602). All "

lib/parse/cmdline.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ def _(self, *args):
791791
advancedHelp = True
792792

793793
for arg in sys.argv:
794-
argv.append(getUnicode(arg, encoding=sys.stdin.encoding))
794+
argv.append(getUnicode(arg, encoding=sys.getfilesystemencoding()))
795795

796796
checkDeprecatedOptions(argv)
797797

0 commit comments

Comments
 (0)