[Python-Dev] Make _strptime only time.strptime implementation?

Guido van Rossum guido@python.org
Sat, 10 May 2003 13:42:51 -0400


> > [Brett]
> > 
> >>>>I got a single email from someone asking me to change the
> >>>>functionality so that it would raise an exception if part of the
> >>>>input string was not parsed.
> >>>
> > [Guido van Rossum]
> > 
> >>>That sounds like a good idea on the face of it.  Or will this break
> >>>existing code?
> > 
> > 
> > [Brett]
> > 
> >>Maybe.  If they depend on some specific behavior on a platform that offers
> >>it, then yes, there could be issues.  But since the docs are so vague if
> >>it does break code it will most likely be because someone didn't follow
> >>the warnings in the spec.
> > 
> > 
> > If you add some flag to control this behavior, defaulting to strict,
> > then at least people who rely on the old (non-strict) behavior can use
> > the flag rather than redesign their application.
> > 
> 
> But the problem is that I have no idea what the old behavior is.  Since 
> the spec is so vague and open I have no clue what all the various libc 
> versions do.  I have just been patching strptime the best I can to 
> handle strange edge cases that pop up and work as people like Kevin need 
> it to.

OK.  Maybe I misunderstood (I've now got to admit that I've never
tried strptime myself).  From your initial message (still quoted
above) I thought that it was a simple case of strptime parsing as much
as it could and then giving up (sort of like sscanf), and that the
suggestion you received was to make it insist on parsing everything or
fail.  I still think that would be a clear improvement.  But if the
original situation wasn't as clear-cut, maybe I should have stayed out
of this...

> Unless you are suggesting a flag that when set controls whether the 
> Python version or a libc version if available is used, which I guess 
> could work as a transition to get people to move over.  Is this what you 
> are getting at, Guido?  And if it is, do you want it at the function or 
> module level?  I say function, but that is because it would be easier to 
> code.  =)

No, that's not what I was going for at all -- I think that would be a
mistake that woud just cause people to worry needlessly about which
strptime version they should use.

--Guido van Rossum (home page: http://www.python.org/~guido/)