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
1f39c28e
Commit
1f39c28e
authored
May 27, 2019
by
Andrew Svetlov
Committed by
Miss Islington (bot)
May 27, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-37035: Don't log OSError (GH-13548)
https://bugs.python.org/issue37035
parent
ff6b2e66
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
35 additions
and
18 deletions
+35
-18
Lib/asyncio/base_events.py
Lib/asyncio/base_events.py
+0
-7
Lib/asyncio/proactor_events.py
Lib/asyncio/proactor_events.py
+1
-1
Lib/asyncio/selector_events.py
Lib/asyncio/selector_events.py
+1
-1
Lib/asyncio/sslproto.py
Lib/asyncio/sslproto.py
+1
-1
Lib/asyncio/unix_events.py
Lib/asyncio/unix_events.py
+1
-1
Lib/test/test_asyncio/test_selector_events.py
Lib/test/test_asyncio/test_selector_events.py
+25
-2
Lib/test/test_asyncio/test_unix_events.py
Lib/test/test_asyncio/test_unix_events.py
+1
-5
Misc/NEWS.d/next/Library/2019-05-24-18-16-07.bpo-37035.HFbJVT.rst
...S.d/next/Library/2019-05-24-18-16-07.bpo-37035.HFbJVT.rst
+5
-0
No files found.
Lib/asyncio/base_events.py
View file @
1f39c28e
...
...
@@ -59,13 +59,6 @@ _MIN_SCHEDULED_TIMER_HANDLES = 100
# before cleanup of cancelled handles is performed.
_MIN_CANCELLED_TIMER_HANDLES_FRACTION
=
0.5
# Exceptions which must not call the exception handler in fatal error
# methods (_fatal_error())
_FATAL_ERROR_IGNORE
=
(
BrokenPipeError
,
ConnectionResetError
,
ConnectionAbortedError
)
if
ssl
is
not
None
:
_FATAL_ERROR_IGNORE
=
_FATAL_ERROR_IGNORE
+
(
ssl
.
SSLCertVerificationError
,)
_HAS_IPv6
=
hasattr
(
socket
,
'AF_INET6'
)
...
...
Lib/asyncio/proactor_events.py
View file @
1f39c28e
...
...
@@ -96,7 +96,7 @@ class _ProactorBasePipeTransport(transports._FlowControlMixin,
def
_fatal_error
(
self
,
exc
,
message
=
'Fatal error on pipe transport'
):
try
:
if
isinstance
(
exc
,
base_events
.
_FATAL_ERROR_IGNORE
):
if
isinstance
(
exc
,
OSError
):
if
self
.
_loop
.
get_debug
():
logger
.
debug
(
"%r: %s"
,
self
,
message
,
exc_info
=
True
)
else
:
...
...
Lib/asyncio/selector_events.py
View file @
1f39c28e
...
...
@@ -685,7 +685,7 @@ class _SelectorTransport(transports._FlowControlMixin,
def
_fatal_error
(
self
,
exc
,
message
=
'Fatal error on transport'
):
# Should be called from exception handler only.
if
isinstance
(
exc
,
base_events
.
_FATAL_ERROR_IGNORE
):
if
isinstance
(
exc
,
OSError
):
if
self
.
_loop
.
get_debug
():
logger
.
debug
(
"%r: %s"
,
self
,
message
,
exc_info
=
True
)
else
:
...
...
Lib/asyncio/sslproto.py
View file @
1f39c28e
...
...
@@ -707,7 +707,7 @@ class SSLProtocol(protocols.Protocol):
self
.
_fatal_error
(
exc
,
'Fatal error on SSL transport'
)
def
_fatal_error
(
self
,
exc
,
message
=
'Fatal error on transport'
):
if
isinstance
(
exc
,
base_events
.
_FATAL_ERROR_IGNORE
):
if
isinstance
(
exc
,
OSError
):
if
self
.
_loop
.
get_debug
():
logger
.
debug
(
"%r: %s"
,
self
,
message
,
exc_info
=
True
)
else
:
...
...
Lib/asyncio/unix_events.py
View file @
1f39c28e
...
...
@@ -724,7 +724,7 @@ class _UnixWritePipeTransport(transports._FlowControlMixin,
def
_fatal_error
(
self
,
exc
,
message
=
'Fatal error on pipe transport'
):
# should be called by exception handler only
if
isinstance
(
exc
,
base_events
.
_FATAL_ERROR_IGNORE
):
if
isinstance
(
exc
,
OSError
):
if
self
.
_loop
.
get_debug
():
logger
.
debug
(
"%r: %s"
,
self
,
message
,
exc_info
=
True
)
else
:
...
...
Lib/test/test_asyncio/test_selector_events.py
View file @
1f39c28e
...
...
@@ -448,10 +448,23 @@ class SelectorTransportTests(test_utils.TestCase):
tr
.
_force_close
=
mock
.
Mock
()
tr
.
_fatal_error
(
exc
)
m_exc
.
assert_not_called
()
tr
.
_force_close
.
assert_called_with
(
exc
)
@
mock
.
patch
(
'asyncio.log.logger.error'
)
def
test_fatal_error_custom_exception
(
self
,
m_exc
):
class
MyError
(
Exception
):
pass
exc
=
MyError
()
tr
=
self
.
create_transport
()
tr
.
_force_close
=
mock
.
Mock
()
tr
.
_fatal_error
(
exc
)
m_exc
.
assert_called_with
(
test_utils
.
MockPattern
(
'Fatal error on transport
\
n
protocol:.*
\
n
transport:.*'
),
exc_info
=
(
OS
Error
,
MOCK_ANY
,
MOCK_ANY
))
exc_info
=
(
My
Error
,
MOCK_ANY
,
MOCK_ANY
))
tr
.
_force_close
.
assert_called_with
(
exc
)
...
...
@@ -1338,10 +1351,20 @@ class SelectorDatagramTransportTests(test_utils.TestCase):
err
=
ConnectionRefusedError
()
transport
.
_fatal_error
(
err
)
self
.
assertFalse
(
self
.
protocol
.
error_received
.
called
)
m_exc
.
assert_not_called
()
@
mock
.
patch
(
'asyncio.base_events.logger.error'
)
def
test_fatal_error_connected_custom_error
(
self
,
m_exc
):
class
MyException
(
Exception
):
pass
transport
=
self
.
datagram_transport
(
address
=
(
'0.0.0.0'
,
1
))
err
=
MyException
()
transport
.
_fatal_error
(
err
)
self
.
assertFalse
(
self
.
protocol
.
error_received
.
called
)
m_exc
.
assert_called_with
(
test_utils
.
MockPattern
(
'Fatal error on transport
\
n
protocol:.*
\
n
transport:.*'
),
exc_info
=
(
ConnectionRefusedError
,
MOCK_ANY
,
MOCK_ANY
))
exc_info
=
(
MyException
,
MOCK_ANY
,
MOCK_ANY
))
if
__name__
==
'__main__'
:
...
...
Lib/test/test_asyncio/test_unix_events.py
View file @
1f39c28e
...
...
@@ -977,11 +977,7 @@ class UnixWritePipeTransportTests(test_utils.TestCase):
self
.
assertFalse
(
self
.
loop
.
readers
)
self
.
assertEqual
(
bytearray
(),
tr
.
_buffer
)
self
.
assertTrue
(
tr
.
is_closing
())
m_logexc
.
assert_called_with
(
test_utils
.
MockPattern
(
'Fatal write error on pipe transport'
'
\
n
protocol:.*
\
n
transport:.*'
),
exc_info
=
(
OSError
,
MOCK_ANY
,
MOCK_ANY
))
m_logexc
.
assert_not_called
()
self
.
assertEqual
(
1
,
tr
.
_conn_lost
)
test_utils
.
run_briefly
(
self
.
loop
)
self
.
protocol
.
connection_lost
.
assert_called_with
(
err
)
...
...
Misc/NEWS.d/next/Library/2019-05-24-18-16-07.bpo-37035.HFbJVT.rst
0 → 100644
View file @
1f39c28e
Don't log OSError based exceptions if a fatal error has occurred in asyncio
transport. Peer can generate almost any OSError, user cannot avoid these exceptions
by fixing own code.
Errors are still propagated to user code, it's just logging them
is pointless and pollute asyncio logs.
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