diff options
author | Benjamin Peterson <benjamin@python.org> | 2009-05-08 20:42:26 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2009-05-08 20:42:26 (GMT) |
commit | 25c95f12987c08f446f355db6b9a807f3dea76a0 (patch) | |
tree | 9d70b6e22b45cec0e40cc6d5d174d03012af7f50 /Lib/logging | |
parent | 8a282d175b5a9f1cd48c5de506fb02d60b20d6d5 (diff) | |
download | cpython-25c95f12987c08f446f355db6b9a807f3dea76a0.zip cpython-25c95f12987c08f446f355db6b9a807f3dea76a0.tar.gz cpython-25c95f12987c08f446f355db6b9a807f3dea76a0.tar.bz2 |
Merged revisions 70768,71657,71721,71729,71794,71976,72036-72037,72079,72085,72131-72134,72191,72197-72198,72219,72221,72225,72303,72434,72467,72476 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r70768 | andrew.kuchling | 2009-03-30 17:29:15 -0500 (Mon, 30 Mar 2009) | 1 line
Typo fixes
........
r71657 | vinay.sajip | 2009-04-16 14:07:37 -0500 (Thu, 16 Apr 2009) | 1 line
Issue #5768: Change to Unicode output logic and test case for same.
........
r71721 | benjamin.peterson | 2009-04-18 14:26:19 -0500 (Sat, 18 Apr 2009) | 1 line
fix a few nits in unittest.py #5771
........
r71729 | benjamin.peterson | 2009-04-18 16:03:10 -0500 (Sat, 18 Apr 2009) | 1 line
move test to a more appropiate one
........
r71794 | vinay.sajip | 2009-04-22 07:10:47 -0500 (Wed, 22 Apr 2009) | 2 lines
Issue #5170: Fixed regression caused when fixing #5768.
........
r71976 | mark.dickinson | 2009-04-26 14:54:55 -0500 (Sun, 26 Apr 2009) | 2 lines
Fix typo in function name
........
r72036 | georg.brandl | 2009-04-27 12:04:23 -0500 (Mon, 27 Apr 2009) | 1 line
#5848: small unittest doc patch.
........
r72037 | georg.brandl | 2009-04-27 12:09:53 -0500 (Mon, 27 Apr 2009) | 1 line
#5840: dont claim we dont support TLS.
........
r72079 | r.david.murray | 2009-04-28 14:02:55 -0500 (Tue, 28 Apr 2009) | 2 lines
Remove spurious 'u'.
........
r72085 | georg.brandl | 2009-04-28 16:48:35 -0500 (Tue, 28 Apr 2009) | 1 line
Make the doctests in the docs pass, except for those in the turtle module.
........
r72131 | benjamin.peterson | 2009-04-29 17:43:35 -0500 (Wed, 29 Apr 2009) | 1 line
fix test_shutil on ZFS #5676
........
r72132 | georg.brandl | 2009-04-29 17:44:07 -0500 (Wed, 29 Apr 2009) | 1 line
#5878: fix repr of re object.
........
r72133 | benjamin.peterson | 2009-04-29 17:44:15 -0500 (Wed, 29 Apr 2009) | 1 line
make sure mode is removable while cleaning up test droppings
........
r72134 | benjamin.peterson | 2009-04-29 19:06:33 -0500 (Wed, 29 Apr 2009) | 1 line
make sure to close file
........
r72191 | michael.foord | 2009-05-02 06:43:06 -0500 (Sat, 02 May 2009) | 9 lines
Adds an exit parameter to unittest.main(). If False main no longer
calls sys.exit.
Closes issue 3379.
Michael Foord
........
r72197 | benjamin.peterson | 2009-05-02 11:24:37 -0500 (Sat, 02 May 2009) | 1 line
don't let sys.argv be used in the tests
........
r72198 | andrew.kuchling | 2009-05-02 12:12:15 -0500 (Sat, 02 May 2009) | 1 line
Add items
........
r72219 | michael.foord | 2009-05-02 15:15:05 -0500 (Sat, 02 May 2009) | 8 lines
Add addCleanup and doCleanups to unittest.TestCase.
Closes issue 5679.
Michael Foord
........
r72221 | benjamin.peterson | 2009-05-02 15:26:53 -0500 (Sat, 02 May 2009) | 1 line
add myself
........
r72225 | michael.foord | 2009-05-02 17:43:34 -0500 (Sat, 02 May 2009) | 1 line
........
r72303 | benjamin.peterson | 2009-05-04 19:55:24 -0500 (Mon, 04 May 2009) | 1 line
using sys._getframe(x), where x > 0 doesnt' work on IronPython
........
r72434 | r.david.murray | 2009-05-07 13:09:58 -0500 (Thu, 07 May 2009) | 2 lines
Pre-opened test file needs to be opened in binary mode.
........
r72467 | georg.brandl | 2009-05-08 07:17:34 -0500 (Fri, 08 May 2009) | 1 line
Fix name.
........
r72476 | thomas.heller | 2009-05-08 15:09:40 -0500 (Fri, 08 May 2009) | 4 lines
Add a file that contains diffs between offical libffi files and the
files in this repository. Should make it easier to merge new libffi
versions.
........
Diffstat (limited to 'Lib/logging')
-rw-r--r-- | Lib/logging/__init__.py | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py index c95cea0..517a7a9 100644 --- a/Lib/logging/__init__.py +++ b/Lib/logging/__init__.py @@ -756,7 +756,7 @@ class StreamHandler(Handler): The record is then written to the stream with a trailing newline. If exception information is present, it is formatted using traceback.print_exception and appended to the stream. If the stream - has an 'encoding' attribute, it is used to encode the message before + has an 'encoding' attribute, it is used to determine how to do the output to the stream. """ try: @@ -767,11 +767,21 @@ class StreamHandler(Handler): stream.write(fs % msg) else: try: - if (isinstance(msg, unicode) or - getattr(stream, 'encoding', None) is None): - stream.write(fs % msg) + 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.encode(stream.encoding)) + stream.write(fs % msg) except UnicodeError: stream.write(fs % msg.encode("UTF-8")) self.flush() |