[Python-checkins] cpython (merge 3.4 -> default): Closes #21172: Merged fix from 3.4.

vinay.sajip python-checkins at python.org
Thu Apr 10 08:14:18 CEST 2014


http://hg.python.org/cpython/rev/8e6b8cfeb172
changeset: 90216:8e6b8cfeb172
parent: 90213:16f090d912d1
parent: 90215:5e303360db14
user: Vinay Sajip <vinay_sajip at yahoo.co.uk>
date: Thu Apr 10 07:14:01 2014 +0100
summary:
 Closes #21172: Merged fix from 3.4.
files:
 Lib/logging/__init__.py | 11 +++++++++--
 Misc/NEWS | 2 ++
 2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py
--- a/Lib/logging/__init__.py
+++ b/Lib/logging/__init__.py
@@ -23,7 +23,8 @@
 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 @@
 # '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)
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -31,6 +31,8 @@
 Library
 -------
 
+- Issue #21172: isinstance check relaxed from dict to collections.Mapping.
+
 - Issue #21155: asyncio.EventLoop.create_unix_server() now raises a ValueError
 if path and sock are specified at the same time.
 
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /