[Python-3000-checkins] r58939 - in python/branches/py3k: Doc/reference/introduction.rst Lib/calendar.py Lib/logging/config.py Objects/descrobject.c

christian.heimes python-3000-checkins at python.org
Mon Nov 12 02:32:03 CET 2007


Author: christian.heimes
Date: Mon Nov 12 02:32:03 2007
New Revision: 58939

Modified:
   python/branches/py3k/   (props changed)
   python/branches/py3k/Doc/reference/introduction.rst
   python/branches/py3k/Lib/calendar.py
   python/branches/py3k/Lib/logging/config.py
   python/branches/py3k/Objects/descrobject.c
Log:
Merged revisions 58930-58938 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r58931 | vinay.sajip | 2007-11-11 15:27:30 +0100 (Sun, 11 Nov 2007) | 1 line
  
  Fixed a bug reported (in private email, by Robert Crida) in logging configuration whereby child loggers of a logger named in a configuration file, which are not themselves named in the configuration, are disabled when the configuration is applied.
........
  r58932 | georg.brandl | 2007-11-11 16:16:16 +0100 (Sun, 11 Nov 2007) | 2 lines
  
  Remove duplication of "this".
........
  r58935 | christian.heimes | 2007-11-12 02:15:40 +0100 (Mon, 12 Nov 2007) | 2 lines
  
  Added new decorator syntax to property.__doc__
  Guido prefers _x over __x.
........
  r58936 | christian.heimes | 2007-11-12 02:20:56 +0100 (Mon, 12 Nov 2007) | 2 lines
  
  Fix for #1427: Error in standard module calendar
  the prweek() method is still broken and I can't figure out how it suppose to work.
........
  r58938 | andrew.kuchling | 2007-11-12 02:25:21 +0100 (Mon, 12 Nov 2007) | 1 line
  
  Re-word sentence
........


Modified: python/branches/py3k/Doc/reference/introduction.rst
==============================================================================
--- python/branches/py3k/Doc/reference/introduction.rst	(original)
+++ python/branches/py3k/Doc/reference/introduction.rst	Mon Nov 12 02:32:03 2007
@@ -58,7 +58,7 @@
 
 Python for .NET
    This implementation actually uses the CPython implementation, but is a managed
-   .NET application and makes .NET libraries available.  This was created by Brian
+   .NET application and makes .NET libraries available.  It was created by Brian
    Lloyd.  For more information, see the `Python for .NET home page
    <http://pythonnet.sourceforge.net>`_.
 

Modified: python/branches/py3k/Lib/calendar.py
==============================================================================
--- python/branches/py3k/Lib/calendar.py	(original)
+++ python/branches/py3k/Lib/calendar.py	Mon Nov 12 02:32:03 2007
@@ -6,7 +6,9 @@
 set the first day of the week (0=Monday, 6=Sunday)."""
 
 from __future__ import with_statement
-import sys, datetime, locale
+import sys
+import datetime
+import locale as _locale
 
 __all__ = ["IllegalMonthError", "IllegalWeekdayError", "setfirstweekday",
            "firstweekday", "isleap", "leapdays", "weekday", "monthrange",
@@ -485,11 +487,11 @@
         self.locale = locale
 
     def __enter__(self):
-        self.oldlocale = locale.setlocale(locale.LC_TIME, self.locale)
-        return locale.getlocale(locale.LC_TIME)[1]
+        self.oldlocale = _locale.setlocale(_locale.LC_TIME, self.locale)
+        return _locale.getlocale(_locale.LC_TIME)[1]
 
     def __exit__(self, *args):
-        locale.setlocale(locale.LC_TIME, self.oldlocale)
+        _locale.setlocale(_locale.LC_TIME, self.oldlocale)
 
 
 class LocaleTextCalendar(TextCalendar):
@@ -503,7 +505,7 @@
     def __init__(self, firstweekday=0, locale=None):
         TextCalendar.__init__(self, firstweekday)
         if locale is None:
-            locale = locale.getdefaultlocale()
+            locale = _locale.getdefaultlocale()
         self.locale = locale
 
     def formatweekday(self, day, width):
@@ -537,7 +539,7 @@
     def __init__(self, firstweekday=0, locale=None):
         HTMLCalendar.__init__(self, firstweekday)
         if locale is None:
-            locale = locale.getdefaultlocale()
+            locale = _locale.getdefaultlocale()
         self.locale = locale
 
     def formatweekday(self, day):
@@ -658,9 +660,11 @@
         parser.error("if --locale is specified --encoding is required")
         sys.exit(1)
 
+    locale = options.locale, options.encoding
+
     if options.type == "html":
         if options.locale:
-            cal = LocaleHTMLCalendar(locale=options.locale)
+            cal = LocaleHTMLCalendar(locale=locale)
         else:
             cal = HTMLCalendar()
         encoding = options.encoding
@@ -676,7 +680,7 @@
             sys.exit(1)
     else:
         if options.locale:
-            cal = LocaleTextCalendar(locale=options.locale)
+            cal = LocaleTextCalendar(locale=locale)
         else:
             cal = TextCalendar()
         optdict = dict(w=options.width, l=options.lines)

Modified: python/branches/py3k/Lib/logging/config.py
==============================================================================
--- python/branches/py3k/Lib/logging/config.py	(original)
+++ python/branches/py3k/Lib/logging/config.py	Mon Nov 12 02:32:03 2007
@@ -1,4 +1,4 @@
-# Copyright 2001-2005 by Vinay Sajip. All Rights Reserved.
+# Copyright 2001-2007 by Vinay Sajip. All Rights Reserved.
 #
 # Permission to use, copy, modify, and distribute this software and its
 # documentation for any purpose and without fee is hereby granted,
@@ -22,7 +22,7 @@
 Should work under Python versions >= 1.5.2, except that source line
 information is not available unless 'sys._getframe()' is.
 
-Copyright (C) 2001-2004 Vinay Sajip. All Rights Reserved.
+Copyright (C) 2001-2007 Vinay Sajip. All Rights Reserved.
 
 To use, simply 'import logging' and log away!
 """
@@ -203,6 +203,14 @@
     #which were in the previous configuration but
     #which are not in the new configuration.
     existing = list(root.manager.loggerDict.keys())
+    #The list needs to be sorted so that we can
+    #avoid disabling child loggers of explicitly
+    #named loggers. With a sorted list it is easier
+    #to find the child loggers.
+    existing.sort()
+    #We'll keep the list of existing loggers
+    #which are children of named loggers here...
+    child_loggers = []
     #now set up the new ones...
     for log in llist:
         sectname = "logger_%s" % log
@@ -214,6 +222,14 @@
             propagate = 1
         logger = logging.getLogger(qn)
         if qn in existing:
+            i = existing.index(qn)
+            prefixed = qn + "."
+            pflen = len(prefixed)
+            num_existing = len(existing)
+            i = i + 1 # look at the entry after qn
+            while (i < num_existing) and (existing[i][:pflen] == prefixed):
+                child_loggers.append(existing[i])
+                i = i + 1
             existing.remove(qn)
         if "level" in opts:
             level = cp.get(sectname, "level")
@@ -231,8 +247,16 @@
     #Disable any old loggers. There's no point deleting
     #them as other threads may continue to hold references
     #and by disabling them, you stop them doing any logging.
+    #However, don't disable children of named loggers, as that's
+    #probably not what was intended by the user.
     for log in existing:
-        root.manager.loggerDict[log].disabled = 1
+        logger = root.manager.loggerDict[log]
+        if log in child_loggers:
+            logger.level = logging.NOTSET
+            logger.handlers = []
+            logger.propagate = 1
+        else:
+            logger.disabled = 1
 
 
 def listen(port=DEFAULT_LOGGING_CONFIG_PORT):

Modified: python/branches/py3k/Objects/descrobject.c
==============================================================================
--- python/branches/py3k/Objects/descrobject.c	(original)
+++ python/branches/py3k/Objects/descrobject.c	Mon Nov 12 02:32:03 2007
@@ -1259,10 +1259,20 @@
 "fset is a function for setting, and fdel a function for del'ing, an\n"
 "attribute.  Typical use is to define a managed attribute x:\n"
 "class C(object):\n"
-"    def getx(self): return self.__x\n"
-"    def setx(self, value): self.__x = value\n"
-"    def delx(self): del self.__x\n"
-"    x = property(getx, setx, delx, \"I'm the 'x' property.\")");
+"    def getx(self): return self._x\n"
+"    def setx(self, value): self._x = value\n"
+"    def delx(self): del self._x\n"
+"    x = property(getx, setx, delx, \"I'm the 'x' property.\")\n"
+"\n"
+"Decorators make defining new properties or modifying existing ones easy:\n"
+"class C(object):\n"
+"    @property\n"
+"    def x(self): return self._x\n"
+"    @x.setter\n"
+"    def x(self, value): self._x = value\n"
+"    @x.deleter\n"
+"    def x(self): del self._x\n"
+);
 
 static int
 property_traverse(PyObject *self, visitproc visit, void *arg)


More information about the Python-3000-checkins mailing list