diff options
author | Matti Picus <matti.picus@gmail.com> | 2019-05-20 12:55:24 +0300 |
---|---|---|
committer | Matti Picus <matti.picus@gmail.com> | 2019-05-20 12:55:24 +0300 |
commit | 630d83bc16c102c120f08abf4116c951e2ab7524 (patch) | |
tree | 7cbc5f5aeeda6a95954978badac426b4db807a69 /lib-python/2.7/logging | |
parent | update the 2.7 stdlib to 2.7.13 (diff) | |
download | pypy-630d83bc16c102c120f08abf4116c951e2ab7524.tar.gz pypy-630d83bc16c102c120f08abf4116c951e2ab7524.tar.bz2 pypy-630d83bc16c102c120f08abf4116c951e2ab7524.zip |
update to v2.7.16
Diffstat (limited to 'lib-python/2.7/logging')
-rw-r--r-- | lib-python/2.7/logging/__init__.py | 19 | ||||
-rw-r--r-- | lib-python/2.7/logging/handlers.py | 27 |
2 files changed, 34 insertions, 12 deletions
diff --git a/lib-python/2.7/logging/__init__.py b/lib-python/2.7/logging/__init__.py index caf151d153..cc24b30900 100644 --- a/lib-python/2.7/logging/__init__.py +++ b/lib-python/2.7/logging/__init__.py @@ -636,12 +636,19 @@ def _removeHandlerRef(wr): # to prevent race conditions and failures during interpreter shutdown. acquire, release, handlers = _acquireLock, _releaseLock, _handlerList if acquire and release and handlers: - acquire() try: - if wr in handlers: - handlers.remove(wr) - finally: - release() + acquire() + try: + if wr in handlers: + handlers.remove(wr) + finally: + release() + except TypeError: + # https://bugs.python.org/issue21149 - If the RLock object behind + # acquire() and release() has been partially finalized you may see + # an error about NoneType not being callable. Absolutely nothing + # we can do in this GC during process shutdown situation. Eat it. + pass def _addHandlerRef(handler): """ @@ -1222,7 +1229,7 @@ class Logger(Filterer): logger.log(level, "We have a %s", "mysterious problem", exc_info=1) """ - if not isinstance(level, int): + if not isinstance(level, (int, long)): if raiseExceptions: raise TypeError("level must be an integer") else: diff --git a/lib-python/2.7/logging/handlers.py b/lib-python/2.7/logging/handlers.py index e430ab7b9b..e0b935c878 100644 --- a/lib-python/2.7/logging/handlers.py +++ b/lib-python/2.7/logging/handlers.py @@ -760,14 +760,29 @@ class SysLogHandler(logging.Handler): self.unixsocket = 1 self._connect_unixsocket(address) else: - self.unixsocket = 0 + self.unixsocket = False if socktype is None: socktype = socket.SOCK_DGRAM - self.socket = socket.socket(socket.AF_INET, socktype) - if socktype == socket.SOCK_STREAM: - self.socket.connect(address) + host, port = address + ress = socket.getaddrinfo(host, port, 0, socktype) + if not ress: + raise socket.error("getaddrinfo returns an empty list") + for res in ress: + af, socktype, proto, _, sa = res + err = sock = None + try: + sock = socket.socket(af, socktype, proto) + if socktype == socket.SOCK_STREAM: + sock.connect(sa) + break + except socket.error as exc: + err = exc + if sock is not None: + sock.close() + if err is not None: + raise err + self.socket = sock self.socktype = socktype - self.formatter = None def _connect_unixsocket(self, address): use_socktype = self.socktype @@ -812,7 +827,7 @@ class SysLogHandler(logging.Handler): priority = self.priority_names[priority] return (facility << 3) | priority - def close (self): + def close(self): """ Closes the socket. """ |