[Patches] [ python-Patches-593560 ] bugfixes and cleanup for _strptime.py

noreply@sourceforge.net noreply@sourceforge.net
Wed, 14 Aug 2002 02:07:53 -0700


Patches item #593560, was opened at 2002-08-10 19:01
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=593560&group_id=5470

Category: Library (Lib)
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Brett Cannon (bcannon)
Assigned to: Nobody/Anonymous (nobody)
Summary: bugfixes and cleanup for _strptime.py

Initial Comment:
Discovered two bugs in _strptime.py thanks to Mikael
Sch?berg of AB Strakt; both were in
LocaleTime.__calc_date_time().  One was where if a
locale-specific format string represented the month
without a leading zero, it would not be caught.  The
other bug was when a locale just lacked some
information (in this case, Swedish's lack of an AM/PM
representation); IndexError was thrown because
string.replace() was being called with the empty string
as the old value.

I also took this opportunity to clean up some of the
code (namely TimeRE.__getitem__() along with
LocaleTime.__calc_date_time()).  Added some comments,
reformatted some code, etc.  All of this was brought on
thanks to the Python Cookbook's chapter 1 (good work
Alex and David!).

I have updated test_strptime.py to check for the second
of the mentioned bug explicitly.  I also commented the
code and added a fxn that creates a PyUnit test suite
with all of the tests.

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

>Comment By: Brett Cannon (bcannon)
Date: 2002-08-14 02:07

Message:
Logged In: YES 
user_id=357491

Just as a follow-up, I got an email from Mikael on Mon.,
2002-08-12, letting me know that the patch seems to have
worked for the bug he discovered.

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

Comment By: Brett Cannon (bcannon)
Date: 2002-08-11 15:16

Message:
Logged In: YES 
user_id=357491

Sorry, Martin.  I thought I remembered reading somewhere
that for Python files you can just post the whole thing.  I
will stop doing that.

As for Mikael and the patch, he says that it appears to be
working.  I gave it to him on Tuesday and he said it
appeared to be working; he has yet to say otherwise.  If you
prefer, I can have him post here to verify this.

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

Comment By: Martin v. Löwis (loewis)
Date: 2002-08-11 10:47

Message:
Logged In: YES 
user_id=21627

Please don't post complete files. Instead, post context (-c)
or unified (-u) diffs. Ideally, produce them with "cvs
diff", as this will result in patches that record the CVS
version number they were for.

I think it would be good to get a comment from Mikael on
that patch.

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

Comment By: Brett Cannon (bcannon)
Date: 2002-08-10 20:31

Message:
Logged In: YES 
user_id=357491

Just when you thought you had something done, tim_one had to
go and normalize the whitespace in both _strptime.py and
test_strptime.py!  =)

So to save Tim the time and effort of having to normalize
the files again, I went ahead and applied them to the fixed
files.  I also reformatted test_strptime.py so that lines
wrapped around 80 characters (didn't realize Guido had added
it to the distro until today).

So make sure to use the files that specify whitespace
normalization in their descriptions.

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

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