mirror of
https://github.com/python/cpython.git
synced 2025-11-02 11:08:57 +00:00
Removed _unicode variable which is always False in Python 3.x.
This commit is contained in:
parent
ec1cd1c475
commit
dc5097ff07
1 changed files with 2 additions and 32 deletions
|
|
@ -53,8 +53,6 @@ __date__ = "07 February 2010"
|
||||||
# Miscellaneous module data
|
# Miscellaneous module data
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
_unicode = 'unicode' in dir(__builtins__)
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# _srcfile is used when walking the stack to check when we've got the first
|
# _srcfile is used when walking the stack to check when we've got the first
|
||||||
# caller stack frame.
|
# caller stack frame.
|
||||||
|
|
@ -313,15 +311,7 @@ class LogRecord(object):
|
||||||
Return the message for this LogRecord after merging any user-supplied
|
Return the message for this LogRecord after merging any user-supplied
|
||||||
arguments with the message.
|
arguments with the message.
|
||||||
"""
|
"""
|
||||||
if not _unicode: #if no unicode support...
|
msg = str(self.msg)
|
||||||
msg = str(self.msg)
|
|
||||||
else:
|
|
||||||
msg = self.msg
|
|
||||||
if not isinstance(msg, str):
|
|
||||||
try:
|
|
||||||
msg = str(self.msg)
|
|
||||||
except UnicodeError:
|
|
||||||
msg = self.msg #Defer encoding till later
|
|
||||||
if self.args:
|
if self.args:
|
||||||
msg = msg % self.args
|
msg = msg % self.args
|
||||||
return msg
|
return msg
|
||||||
|
|
@ -838,27 +828,7 @@ class StreamHandler(Handler):
|
||||||
msg = self.format(record)
|
msg = self.format(record)
|
||||||
stream = self.stream
|
stream = self.stream
|
||||||
fs = "%s\n"
|
fs = "%s\n"
|
||||||
if not _unicode: #if no unicode support...
|
stream.write(fs % msg)
|
||||||
stream.write(fs % msg)
|
|
||||||
else:
|
|
||||||
try:
|
|
||||||
if (isinstance(msg, unicode) and
|
|
||||||
getattr(stream, 'encoding', None)):
|
|
||||||
fs = fs.decode(stream.encoding)
|
|
||||||
try:
|
|
||||||
stream.write(fs % msg)
|
|
||||||
except UnicodeEncodeError:
|
|
||||||
#Printing to terminals sometimes fails. For example,
|
|
||||||
#with an encoding of 'cp1251', the above write will
|
|
||||||
#work if written to a stream opened or wrapped by
|
|
||||||
#the codecs module, but fail when writing to a
|
|
||||||
#terminal even when the codepage is set to cp1251.
|
|
||||||
#An extra encoding step seems to be needed.
|
|
||||||
stream.write((fs % msg).encode(stream.encoding))
|
|
||||||
else:
|
|
||||||
stream.write(fs % msg)
|
|
||||||
except UnicodeError:
|
|
||||||
stream.write(fs % msg.encode("UTF-8"))
|
|
||||||
self.flush()
|
self.flush()
|
||||||
except (KeyboardInterrupt, SystemExit):
|
except (KeyboardInterrupt, SystemExit):
|
||||||
raise
|
raise
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue