Skip to content

Commit 71dcb28

Browse files
committed
Issue #20558: Improved implementation of error handling.
1 parent ecfc98c commit 71dcb28

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

Lib/logging/config.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2001-2013 by Vinay Sajip. All Rights Reserved.
1+
# Copyright 2001-2014 by Vinay Sajip. All Rights Reserved.
22
#
33
# Permission to use, copy, modify, and distribute this software and its
44
# documentation for any purpose and without fee is hereby granted,
@@ -19,13 +19,19 @@
1919
is based on PEP 282 and comments thereto in comp.lang.python, and influenced
2020
by Apache's log4j system.
2121
22-
Copyright (C) 2001-2013 Vinay Sajip. All Rights Reserved.
22+
Copyright (C) 2001-2014 Vinay Sajip. All Rights Reserved.
2323
2424
To use, simply 'import logging' and log away!
2525
"""
2626

27-
import sys, logging, logging.handlers, struct, traceback, re
27+
import errno
2828
import io
29+
import logging
30+
import logging.handlers
31+
import re
32+
import struct
33+
import sys
34+
import traceback
2935

3036
try:
3137
import _thread as thread
@@ -38,10 +44,7 @@
3844

3945
DEFAULT_LOGGING_CONFIG_PORT = 9030
4046

41-
if sys.platform == "win32":
42-
RESET_ERROR = 10054 #WSAECONNRESET
43-
else:
44-
RESET_ERROR = 104 #ECONNRESET
47+
RESET_ERROR = errno.ECONNRESET
4548

4649
#
4750
# The following code implements a socket listener for on-the-fly
@@ -867,12 +870,8 @@ def handle(self):
867870
if self.server.ready:
868871
self.server.ready.set()
869872
except OSError as e:
870-
if not isinstance(e.args, tuple):
873+
if e.errno != RESET_ERROR:
871874
raise
872-
else:
873-
errcode = e.args[0]
874-
if errcode != RESET_ERROR:
875-
raise
876875

877876
class ConfigSocketReceiver(ThreadingTCPServer):
878877
"""

0 commit comments

Comments
 (0)