diff options
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/logging/config.py | 26 | ||||
-rw-r--r-- | Lib/test/test_logging.py | 2 |
2 files changed, 19 insertions, 9 deletions
diff --git a/Lib/logging/config.py b/Lib/logging/config.py index 1e5ff68..63193b1 100644 --- a/Lib/logging/config.py +++ b/Lib/logging/config.py @@ -386,15 +386,21 @@ class BaseConfigurator(object): """ name = s.split('.') used = name.pop(0) - found = self.importer(used) - for frag in name: - used += '.' + frag - try: - found = getattr(found, frag) - except AttributeError: - self.importer(used) - found = getattr(found, frag) - return found + try: + found = self.importer(used) + for frag in name: + used += '.' + frag + try: + found = getattr(found, frag) + except AttributeError: + self.importer(used) + found = getattr(found, frag) + return found + except ImportError: + e, tb = sys.exc_info()[1:] + v = ValueError('Cannot resolve %r: %s' % (s, e)) + v.__cause__, v.__traceback__ = e, tb + raise v def ext_convert(self, value): """Default converter for the ext:// protocol.""" @@ -873,6 +879,8 @@ def listen(port=DEFAULT_LOGGING_CONFIG_PORT): def run(self): server = self.rcvr(port=self.port, handler=self.hdlr, ready=self.ready) + if self.port == 0: + self.port = server.server_address[1] self.ready.set() global _listener logging._acquireLock() diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py index c884d3e..d763459 100644 --- a/Lib/test/test_logging.py +++ b/Lib/test/test_logging.py @@ -1670,6 +1670,8 @@ class ConfigDictTest(BaseTest): t = logging.config.listen(port) t.start() t.ready.wait() + # Now get the port allocated + port = t.port t.ready.clear() try: sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) |