Do you know of a work around?

I can probably provide a simple one by looking for a blank between the time and date.

Wayne Watson wrote:
Thanks. Yes, 2.4 for Win.

Now to find out if the fellow who wrote the s/w package I'm writing a utility for can move his s/w to 2.4.

Martin Walsh wrote:
Wayne Watson wrote:
  
This program segment allows an invalid date to go undetected. See below.

    def set_time_stamp(d1):
        # yyyy/mm/dd hh:mm:ss in, vyyyymmdd_hhmmss.27 out
        formatin = '%Y/%m/%d %H:%M:%S'
        d1 = d1.lstrip()
        try:
            date1 = datetime(*(time.strptime(d1, formatin)[0:6]))
        except ValueError:
            print; print "Invalid date input. Use yyyy/mm/dd hh:mm:ss."
            return False
    
<snip>
  
    Enter date and time: 2008/1/100:00:30     <- Why is this valid. The
    fields are not spearated.
    dout:  20080110_000030
    prefix:  v20080110_000030.27
    OK:  v20080110_000030.27

    


I have confirmed there is a difference in the behavior of time.strptime
between python 2.4 and 2.5, and I assume you're using 2.4.

It is possibly related to this bug (but hard to say for sure without
looking at the source)...

 http://bugs.python.org/issue1340337

... and the subsequent fix for 2.5. But, clearly something changed
between releases.

from http://www.python.org/download/releases/2.5/NEWS.txt
"""
- Bug #1340337: change time.strptime() to always return ValueError when
there is an error in the format string.
- Bug #1290505: Fix clearing the regex cache for time.strptime().
"""

HTH,
Marty
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

  

--
Signature.html
           Wayne Watson (Watson Adventures, Prop., Nevada City, CA)

             (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
              Obz Site:  39° 15' 7" N, 121° 2' 32" W, 2700 feet
            
          "If voting made any difference they wouldn't let us do it." 
                        -- Mark Twain
            
                    Web Page: <www.speckledwithstars.net/>

_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

--
Signature.html
           Wayne Watson (Watson Adventures, Prop., Nevada City, CA)

             (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
              Obz Site:  39° 15' 7" N, 121° 2' 32" W, 2700 feet
            
          "If voting made any difference they wouldn't let us do it." 
                        -- Mark Twain
            
                    Web Page: <www.speckledwithstars.net/>
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to