[Python-checkins] r58936 - python/trunk/Lib/calendar.py

christian.heimes python-checkins at python.org
Mon Nov 12 02:20:56 CET 2007


Author: christian.heimes
Date: Mon Nov 12 02:20:56 2007
New Revision: 58936
Modified:
 python/trunk/Lib/calendar.py
Log:
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.
Modified: python/trunk/Lib/calendar.py
==============================================================================
--- python/trunk/Lib/calendar.py	(original)
+++ python/trunk/Lib/calendar.py	Mon Nov 12 02:20:56 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)


More information about the Python-checkins mailing list

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