diff options
author | Guido van Rossum <guido@python.org> | 2007-06-07 23:15:56 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2007-06-07 23:15:56 (GMT) |
commit | 1325790b932c4bab4f8f94f5a36c09f4036ed9f8 (patch) | |
tree | 5f4c1d854783a4d082c5867094ec345f4772bf35 /Lib/logging | |
parent | 7b955bd125951db694f19a1b8648b806b14bd61f (diff) | |
download | cpython-1325790b932c4bab4f8f94f5a36c09f4036ed9f8.zip cpython-1325790b932c4bab4f8f94f5a36c09f4036ed9f8.tar.gz cpython-1325790b932c4bab4f8f94f5a36c09f4036ed9f8.tar.bz2 |
Merged revisions 55795-55816 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/p3yk
........
r55797 | neal.norwitz | 2007-06-07 00:00:57 -0700 (Thu, 07 Jun 2007) | 3 lines
Get rid of some remnants of classic classes. types.ClassType == type.
Also get rid of almost all uses of the types module and use the builtin name.
........
r55798 | neal.norwitz | 2007-06-07 00:12:36 -0700 (Thu, 07 Jun 2007) | 1 line
Remove a use of types, verify commit hook works
........
r55809 | guido.van.rossum | 2007-06-07 11:11:29 -0700 (Thu, 07 Jun 2007) | 2 lines
Fix syntax error introduced by Neal in last checkin.
........
Diffstat (limited to 'Lib/logging')
-rw-r--r-- | Lib/logging/__init__.py | 16 | ||||
-rw-r--r-- | Lib/logging/config.py | 4 | ||||
-rw-r--r-- | Lib/logging/handlers.py | 14 |
3 files changed, 18 insertions, 16 deletions
diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py index 0a62886..6dc5387 100644 --- a/Lib/logging/__init__.py +++ b/Lib/logging/__init__.py @@ -26,7 +26,7 @@ Copyright (C) 2001-2007 Vinay Sajip. All Rights Reserved. To use, simply 'import logging' and log away! """ -import sys, os, types, time, cStringIO, traceback +import sys, os, time, cStringIO, traceback try: import codecs @@ -48,6 +48,8 @@ __date__ = "16 February 2007" # Miscellaneous module data #--------------------------------------------------------------------------- +_unicode = 'unicode' in dir(__builtins__) + # # _srcfile is used when walking the stack to check when we've got the first # caller stack frame. @@ -234,7 +236,7 @@ class LogRecord: # 'Value is %d' instead of 'Value is 0'. # For the use case of passing a dictionary, this should not be a # problem. - if args and (len(args) == 1) and args[0] and (type(args[0]) == types.DictType): + if args and (len(args) == 1) and args[0] and isinstance(args[0], dict): args = args[0] self.args = args self.levelname = getLevelName(level) @@ -275,11 +277,11 @@ class LogRecord: Return the message for this LogRecord after merging any user-supplied arguments with the message. """ - if not hasattr(types, "UnicodeType"): #if no unicode support... + if not _unicode: #if no unicode support... msg = str(self.msg) else: msg = self.msg - if type(msg) not in (types.UnicodeType, types.StringType): + if not isinstance(msg, basestring): try: msg = str(self.msg) except UnicodeError: @@ -743,7 +745,7 @@ class StreamHandler(Handler): try: msg = self.format(record) fs = "%s\n" - if not hasattr(types, "UnicodeType"): #if no unicode support... + if not _unicode: #if no unicode support... self.stream.write(fs % msg) else: try: @@ -1053,7 +1055,7 @@ class Logger(Filterer): logger.log(level, "We have a %s", "mysterious problem", exc_info=1) """ - if type(level) != types.IntType: + if not isinstance(level, int): if raiseExceptions: raise TypeError, "level must be an integer" else: @@ -1103,7 +1105,7 @@ class Logger(Filterer): else: fn, lno, func = "(unknown file)", 0, "(unknown function)" if exc_info: - if type(exc_info) != types.TupleType: + if not isinstance(exc_info, tuple): exc_info = sys.exc_info() record = self.makeRecord(self.name, level, fn, lno, msg, args, exc_info, func, extra) self.handle(record) diff --git a/Lib/logging/config.py b/Lib/logging/config.py index 8b28153..0bf79a5 100644 --- a/Lib/logging/config.py +++ b/Lib/logging/config.py @@ -27,7 +27,7 @@ Copyright (C) 2001-2004 Vinay Sajip. All Rights Reserved. To use, simply 'import logging' and log away! """ -import sys, logging, logging.handlers, socket, struct, os, traceback, types +import sys, logging, logging.handlers, socket, struct, os, traceback try: import thread @@ -289,7 +289,7 @@ def listen(port=DEFAULT_LOGGING_CONFIG_PORT): traceback.print_exc() os.remove(file) except socket.error as e: - if type(e.args) != types.TupleType: + if not isinstancetype(e.args, tuple): raise else: errcode = e.args[0] diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py index 084a932..75434b7 100644 --- a/Lib/logging/handlers.py +++ b/Lib/logging/handlers.py @@ -27,7 +27,7 @@ Copyright (C) 2001-2007 Vinay Sajip. All Rights Reserved. To use, simply 'import logging' and log away! """ -import sys, logging, socket, types, os, struct, time, glob +import sys, logging, socket, os, struct, time, glob try: import cPickle as pickle except ImportError: @@ -637,7 +637,7 @@ class SysLogHandler(logging.Handler): self.address = address self.facility = facility - if type(address) == types.StringType: + if isinstance(address, str): self.unixsocket = 1 self._connect_unixsocket(address) else: @@ -669,9 +669,9 @@ class SysLogHandler(logging.Handler): priority_names mapping dictionaries are used to convert them to integers. """ - if type(facility) == types.StringType: + if isinstance(facility, str): facility = self.facility_names[facility] - if type(priority) == types.StringType: + if isinstance(priority, str): priority = self.priority_names[priority] return (facility << 3) | priority @@ -738,16 +738,16 @@ class SMTPHandler(logging.Handler): for the credentials argument. """ logging.Handler.__init__(self) - if type(mailhost) == types.TupleType: + if isinstance(mailhost, tuple): self.mailhost, self.mailport = mailhost else: self.mailhost, self.mailport = mailhost, None - if type(credentials) == types.TupleType: + if isinstance(credentials, tuple): self.username, self.password = credentials else: self.username = None self.fromaddr = fromaddr - if type(toaddrs) == types.StringType: + if isinstance(toaddrs, str): toaddrs = [toaddrs] self.toaddrs = toaddrs self.subject = subject |