[Python-Dev] Make _strptime only time.strptime implementation? (original) (raw)

Brett C. drifty@alum.berkeley.edu
Fri, 09 May 2003 19:13:35 -0700


Guido van Rossum wrote:

[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.

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. =)

And while we are on this subject, does anyone have any issues if I cause _strptime to recognize UTC and GMT as timezones? The Solaris box I always use to do libc strptime comparisons to does not recognize it as an acceptable value for %Z, but since it is a known fact that neither have daylight savings I feel strptime should recognize this fact and set the daylight savings value to 0 insteading of raising an error saying it doesn't know about that timezone.

Any objections to the change? Go for it.

Great. Once we have settled on this possible strict flag I will make the change to _strptime.

-Brett