Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
65d66e10
Commit
65d66e10
authored
Sep 04, 2008
by
Vinay Sajip
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #3772: Fixed regression problem in StreamHandler.emit().
parent
a0b7444f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
3 deletions
+31
-3
Lib/logging/__init__.py
Lib/logging/__init__.py
+1
-1
Lib/test/test_logging.py
Lib/test/test_logging.py
+27
-1
Misc/NEWS
Misc/NEWS
+3
-1
No files found.
Lib/logging/__init__.py
View file @
65d66e10
...
...
@@ -757,7 +757,7 @@ class StreamHandler(Handler):
self
.
stream
.
write
(
fs
%
msg
)
else
:
try
:
if
hasattr
(
self
.
stream
,
'encoding'
)
:
if
getattr
(
self
.
stream
,
'encoding'
,
None
)
is
not
None
:
self
.
stream
.
write
(
fs
%
msg
.
encode
(
self
.
stream
.
encoding
))
else
:
self
.
stream
.
write
(
fs
%
msg
)
...
...
Lib/test/test_logging.py
View file @
65d66e10
...
...
@@ -859,6 +859,31 @@ class MemoryTest(BaseTest):
('foo', 'DEBUG', '3'),
])
class EncodingTest(BaseTest):
def test_encoding_plain_file(self):
# In Python 2.x, a plain file object is treated as having no encoding.
log = logging.getLogger("
test
")
fn = tempfile.mktemp("
.
log
")
# the non-ascii data we write to the log.
data = "
foo
\
x80
"
try:
handler = logging.FileHandler(fn)
log.addHandler(handler)
try:
# write non-ascii data to the log.
log.warning(data)
finally:
log.removeHandler(handler)
handler.close()
# check we wrote exactly those bytes, ignoring trailing
\
n
etc
f = open(fn)
try:
self.failUnlessEqual(f.read().rstrip(), data)
finally:
f.close()
finally:
if os.path.isfile(fn):
os.remove(fn)
# Set the locale to the platform-dependent default. I have no idea
# why the test does this, but in any case we save the current locale
...
...
@@ -867,7 +892,8 @@ class MemoryTest(BaseTest):
def test_main():
run_unittest(BuiltinLevelsTest, BasicFilterTest,
CustomLevelsAndFiltersTest, MemoryHandlerTest,
ConfigFileTest, SocketHandlerTest, MemoryTest)
ConfigFileTest, SocketHandlerTest, MemoryTest,
EncodingTest)
if __name__ == "
__main__
":
test_main()
Misc/NEWS
View file @
65d66e10
...
...
@@ -56,6 +56,8 @@ C-API
Library
-------
- Issue #3772: Fixed regression problem in StreamHandler.emit().
- Issue 600362: Relocated parse_qs() and parse_qsl(), from the cgi module
to the urlparse one. Added a PendingDeprecationWarning in the old
module, it will be deprecated in the future.
...
...
@@ -87,7 +89,7 @@ Library
- Issue #3708: os.urandom no longer goes into an infinite loop when passed a
non-integer floating point number.
- Issue #3110: multiprocessing fails to compiel on solaris 10 due to missing
- Issue #3110: multiprocessing fails to compiel on solaris 10 due to missing
SEM_VALUE_MAX.
Extension Modules
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment