[Patches] [ python-Patches-503202 ] backward compat. on calendar.py

noreply@sourceforge.net noreply@sourceforge.net
Thu, 14 Mar 2002 19:08:17 -0800


Patches item #503202, was opened at 2002-01-14 00:47
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=503202&group_id=5470

Category: Library (Lib)
Group: Python 2.2.x
Status: Open
Resolution: None
Priority: 7
Submitted By: Hye-Shik Chang (perky)
>Assigned to: Skip Montanaro (montanaro)
Summary: backward compat. on calendar.py

Initial Comment:
Many applications fails on 2.2 by this problem:

under 2.1.1 ---
>>> import calendar
>>> for n in calendar.day_abbr:
...     print n,
... 
Mon Tue Wed Thu Fri Sat Sun
>>> calendar.month_abbr[7:]
['Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']


2.2 ---
>>> import calendar
>>> for n in calendar.day_abbr:
...     print n,
... 
Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat 
Sun Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri 
Sat Sun Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu 
Fri Sat Sun Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed 
Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat Sun Mon Tue 
Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat Sun Mon 
Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat Sun 
Mon Tue Wed Thu Fri Sat Sun Mon Tue
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/pkg/lib/python2.2/calendar.py", line 31, 
in __getitem__
    return strftime(self.format, (item,)*9).capitalize
()
ValueError: year out of range
>>> calendar.month_abbr[7:]
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/pkg/lib/python2.2/calendar.py", line 31, 
in __getitem__
    return strftime(self.format, (item,)*9).capitalize
()
TypeError: an integer is required
>>> 

----------------------------------------------------------------------

>Comment By: Barry Warsaw (bwarsaw)
Date: 2002-03-14 22:08

Message:
Logged In: YES 
user_id=12800

Go for it Skip!

----------------------------------------------------------------------

Comment By: Skip Montanaro (montanaro)
Date: 2002-03-14 20:41

Message:
Logged In: YES 
user_id=44345

Looks to me like adding

    if item > 6 or item < -7:
        raise IndexError

to the start of _localized_name.__getitem__ will do the 
trick.  (Should a test for non-integer items also be
added?)

Skip


----------------------------------------------------------------------

Comment By: Tim Peters (tim_one)
Date: 2002-03-14 18:05

Message:
Logged In: YES 
user_id=31435

Based on Guido's comment, categorized as 2.2.x and boosted 
priority to 7.

----------------------------------------------------------------------

Comment By: Guido van Rossum (gvanrossum)
Date: 2002-01-14 01:18

Message:
Logged In: YES 
user_id=6380

You're right. Assigned to Barry.

I propose that the test suite should be changed to test for
this.

This would be a 2.2.1 bugfix candidate!

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=503202&group_id=5470