]> granicus.if.org Git - python/commitdiff
Added checks for tuples in dictConfig.
authorVinay Sajip <vinay_sajip@yahoo.co.uk>
Sat, 6 Mar 2010 15:56:03 +0000 (15:56 +0000)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>
Sat, 6 Mar 2010 15:56:03 +0000 (15:56 +0000)
Lib/logging/config.py

index 7a2188f2425df1d07ef31e7efd163eebfc7eca71..21e10c14f574ef2bd8cb6392d66ed06206bbbd30 100644 (file)
@@ -474,6 +474,12 @@ class BaseConfigurator(object):
                 setattr(result, name, value)
         return result
 
+    def as_tuple(self, value):
+        """Utility function which converts lists to tuples."""
+        if isinstance(value, list):
+            value = tuple(value)
+        return value
+
 class DictConfigurator(BaseConfigurator):
     """
     Configure logging using a dictionary-like object to describe the
@@ -688,6 +694,12 @@ class DictConfigurator(BaseConfigurator):
                 except StandardError, e:
                     raise ValueError('Unable to set target handler '
                                      '%r: %s' % (config['target'], e))
+            elif issubclass(klass, logging.handlers.SMTPHandler) and\
+                'mailhost' in config:
+                config['mailhost'] = self.as_tuple(config['mailhost'])
+            elif issubclass(klass, logging.handlers.SysLogHandler) and\
+                'address' in config:
+                config['address'] = self.as_tuple(config['address'])
             factory = klass
         kwargs = dict([(k, config[k]) for k in config if valid_ident(k)])
         try: