summaryrefslogtreecommitdiffstats
path: root/Lib/logging
diff options
context:
space:
mode:
authorVinay Sajip <vinay_sajip@yahoo.co.uk>2014-04-10 06:12:19 (GMT)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>2014-04-10 06:12:19 (GMT)
commit1b7611405d80df5387cad6492b7b12436450cced (patch)
tree3157702a9baf0a029ae080e76c775dbc6f5e922c /Lib/logging
parent0654be18b387cbd136bfb62d77849111a954b58b (diff)
downloadcpython-1b7611405d80df5387cad6492b7b12436450cced.zip
cpython-1b7611405d80df5387cad6492b7b12436450cced.tar.gz
cpython-1b7611405d80df5387cad6492b7b12436450cced.tar.bz2
Issue #21172: isinstance check relaxed from dict to collections.Mapping.
Diffstat (limited to 'Lib/logging')
-rw-r--r--Lib/logging/__init__.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py
index 181bc15..dcfd9f6 100644
--- a/Lib/logging/__init__.py
+++ b/Lib/logging/__init__.py
@@ -23,7 +23,8 @@ Copyright (C) 2001-2014 Vinay Sajip. All Rights Reserved.
To use, simply 'import logging' and log away!
"""
-import sys, os, time, io, traceback, warnings, weakref
+import sys, os, time, io, traceback, warnings, weakref, collections
+
from string import Template
__all__ = ['BASIC_FORMAT', 'BufferingFormatter', 'CRITICAL', 'DEBUG', 'ERROR',
@@ -253,7 +254,13 @@ class LogRecord(object):
# '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 isinstance(args[0], dict) and args[0]:
+ # Issue #21172: a request was made to relax the isinstance check
+ # to hasattr(args[0], '__getitem__'). However, the docs on string
+ # formatting still seem to suggest a mapping object is required.
+ # Thus, while not removing the isinstance check, it does now look
+ # for collections.Mapping rather than, as before, dict.
+ if (args and len(args) == 1 and isinstance(args[0], collections.Mapping)
+ and args[0]):
args = args[0]
self.args = args
self.levelname = getLevelName(level)