Skip to content

Commit 96f3163

Browse files
committed
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 ........
1 parent 29fd712 commit 96f3163

File tree

4 files changed

+54
-16
lines changed

4 files changed

+54
-16
lines changed

Doc/reference/introduction.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Jython
5858

5959
Python for .NET
6060
This implementation actually uses the CPython implementation, but is a managed
61-
.NET application and makes .NET libraries available. This was created by Brian
61+
.NET application and makes .NET libraries available. It was created by Brian
6262
Lloyd. For more information, see the `Python for .NET home page
6363
<http://pythonnet.sourceforge.net>`_.
6464

Lib/calendar.py

+12-8
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
set the first day of the week (0=Monday, 6=Sunday)."""
77

88
from __future__ import with_statement
9-
import sys, datetime, locale
9+
import sys
10+
import datetime
11+
import locale as _locale
1012

1113
__all__ = ["IllegalMonthError", "IllegalWeekdayError", "setfirstweekday",
1214
"firstweekday", "isleap", "leapdays", "weekday", "monthrange",
@@ -485,11 +487,11 @@ def __init__(self, locale):
485487
self.locale = locale
486488

487489
def __enter__(self):
488-
self.oldlocale = locale.setlocale(locale.LC_TIME, self.locale)
489-
return locale.getlocale(locale.LC_TIME)[1]
490+
self.oldlocale = _locale.setlocale(_locale.LC_TIME, self.locale)
491+
return _locale.getlocale(_locale.LC_TIME)[1]
490492

491493
def __exit__(self, *args):
492-
locale.setlocale(locale.LC_TIME, self.oldlocale)
494+
_locale.setlocale(_locale.LC_TIME, self.oldlocale)
493495

494496

495497
class LocaleTextCalendar(TextCalendar):
@@ -503,7 +505,7 @@ class LocaleTextCalendar(TextCalendar):
503505
def __init__(self, firstweekday=0, locale=None):
504506
TextCalendar.__init__(self, firstweekday)
505507
if locale is None:
506-
locale = locale.getdefaultlocale()
508+
locale = _locale.getdefaultlocale()
507509
self.locale = locale
508510

509511
def formatweekday(self, day, width):
@@ -537,7 +539,7 @@ class LocaleHTMLCalendar(HTMLCalendar):
537539
def __init__(self, firstweekday=0, locale=None):
538540
HTMLCalendar.__init__(self, firstweekday)
539541
if locale is None:
540-
locale = locale.getdefaultlocale()
542+
locale = _locale.getdefaultlocale()
541543
self.locale = locale
542544

543545
def formatweekday(self, day):
@@ -658,9 +660,11 @@ def main(args):
658660
parser.error("if --locale is specified --encoding is required")
659661
sys.exit(1)
660662

663+
locale = options.locale, options.encoding
664+
661665
if options.type == "html":
662666
if options.locale:
663-
cal = LocaleHTMLCalendar(locale=options.locale)
667+
cal = LocaleHTMLCalendar(locale=locale)
664668
else:
665669
cal = HTMLCalendar()
666670
encoding = options.encoding
@@ -676,7 +680,7 @@ def main(args):
676680
sys.exit(1)
677681
else:
678682
if options.locale:
679-
cal = LocaleTextCalendar(locale=options.locale)
683+
cal = LocaleTextCalendar(locale=locale)
680684
else:
681685
cal = TextCalendar()
682686
optdict = dict(w=options.width, l=options.lines)

Lib/logging/config.py

+27-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2001-2005 by Vinay Sajip. All Rights Reserved.
1+
# Copyright 2001-2007 by Vinay Sajip. All Rights Reserved.
22
#
33
# Permission to use, copy, modify, and distribute this software and its
44
# documentation for any purpose and without fee is hereby granted,
@@ -22,7 +22,7 @@
2222
Should work under Python versions >= 1.5.2, except that source line
2323
information is not available unless 'sys._getframe()' is.
2424
25-
Copyright (C) 2001-2004 Vinay Sajip. All Rights Reserved.
25+
Copyright (C) 2001-2007 Vinay Sajip. All Rights Reserved.
2626
2727
To use, simply 'import logging' and log away!
2828
"""
@@ -203,6 +203,14 @@ def _install_loggers(cp, handlers):
203203
#which were in the previous configuration but
204204
#which are not in the new configuration.
205205
existing = list(root.manager.loggerDict.keys())
206+
#The list needs to be sorted so that we can
207+
#avoid disabling child loggers of explicitly
208+
#named loggers. With a sorted list it is easier
209+
#to find the child loggers.
210+
existing.sort()
211+
#We'll keep the list of existing loggers
212+
#which are children of named loggers here...
213+
child_loggers = []
206214
#now set up the new ones...
207215
for log in llist:
208216
sectname = "logger_%s" % log
@@ -214,6 +222,14 @@ def _install_loggers(cp, handlers):
214222
propagate = 1
215223
logger = logging.getLogger(qn)
216224
if qn in existing:
225+
i = existing.index(qn)
226+
prefixed = qn + "."
227+
pflen = len(prefixed)
228+
num_existing = len(existing)
229+
i = i + 1 # look at the entry after qn
230+
while (i < num_existing) and (existing[i][:pflen] == prefixed):
231+
child_loggers.append(existing[i])
232+
i = i + 1
217233
existing.remove(qn)
218234
if "level" in opts:
219235
level = cp.get(sectname, "level")
@@ -231,8 +247,16 @@ def _install_loggers(cp, handlers):
231247
#Disable any old loggers. There's no point deleting
232248
#them as other threads may continue to hold references
233249
#and by disabling them, you stop them doing any logging.
250+
#However, don't disable children of named loggers, as that's
251+
#probably not what was intended by the user.
234252
for log in existing:
235-
root.manager.loggerDict[log].disabled = 1
253+
logger = root.manager.loggerDict[log]
254+
if log in child_loggers:
255+
logger.level = logging.NOTSET
256+
logger.handlers = []
257+
logger.propagate = 1
258+
else:
259+
logger.disabled = 1
236260

237261

238262
def listen(port=DEFAULT_LOGGING_CONFIG_PORT):

Objects/descrobject.c

+14-4
Original file line numberDiff line numberDiff line change
@@ -1259,10 +1259,20 @@ PyDoc_STRVAR(property_doc,
12591259
"fset is a function for setting, and fdel a function for del'ing, an\n"
12601260
"attribute. Typical use is to define a managed attribute x:\n"
12611261
"class C(object):\n"
1262-
" def getx(self): return self.__x\n"
1263-
" def setx(self, value): self.__x = value\n"
1264-
" def delx(self): del self.__x\n"
1265-
" x = property(getx, setx, delx, \"I'm the 'x' property.\")");
1262+
" def getx(self): return self._x\n"
1263+
" def setx(self, value): self._x = value\n"
1264+
" def delx(self): del self._x\n"
1265+
" x = property(getx, setx, delx, \"I'm the 'x' property.\")\n"
1266+
"\n"
1267+
"Decorators make defining new properties or modifying existing ones easy:\n"
1268+
"class C(object):\n"
1269+
" @property\n"
1270+
" def x(self): return self._x\n"
1271+
" @x.setter\n"
1272+
" def x(self, value): self._x = value\n"
1273+
" @x.deleter\n"
1274+
" def x(self): del self._x\n"
1275+
);
12661276

12671277
static int
12681278
property_traverse(PyObject *self, visitproc visit, void *arg)

0 commit comments

Comments
 (0)