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
ca87eebb
Commit
ca87eebb
authored
May 07, 2019
by
Riccardo Magliocchetti
Committed by
Vinay Sajip
May 07, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-36015: Handle StreamHandler representaton of stream with an integer name (GH-11908)
parent
3918ad6b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
0 deletions
+10
-0
Lib/logging/__init__.py
Lib/logging/__init__.py
+2
-0
Lib/test/test_logging.py
Lib/test/test_logging.py
+8
-0
No files found.
Lib/logging/__init__.py
View file @
ca87eebb
...
...
@@ -1111,6 +1111,8 @@ class StreamHandler(Handler):
def
__repr__
(
self
):
level
=
getLevelName
(
self
.
level
)
name
=
getattr
(
self
.
stream
,
'name'
,
''
)
# bpo-36015: name can be an int
name
=
str
(
name
)
if
name
:
name
+=
' '
return
'<%s %s(%s)>'
%
(
self
.
__class__
.
__name__
,
name
,
level
)
...
...
Lib/test/test_logging.py
View file @
ca87eebb
...
...
@@ -760,6 +760,10 @@ class TestStreamHandler(logging.StreamHandler):
def handleError(self, record):
self.error_record = record
class StreamWithIntName(object):
level = logging.NOTSET
name = 2
class StreamHandlerTest(BaseTest):
def test_error_handling(self):
h = TestStreamHandler(BadStream())
...
...
@@ -797,6 +801,10 @@ class StreamHandlerTest(BaseTest):
actual = h.setStream(old)
self.assertIsNone(actual)
def test_can_represent_stream_with_int_name(self):
h = logging.StreamHandler(StreamWithIntName())
self.assertEqual(repr(h), '<StreamHandler 2 (NOTSET)>')
# -- The following section could be moved into a server_helper.py module
# -- if it proves to be of wider utility than just test_logging
...
...
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