[GHC] #9150: libraries/time: parseTime barfs on leading space in format string
GHC
ghc-devs at haskell.org
Mon Jul 21 17:01:33 UTC 2014
#9150: libraries/time: parseTime barfs on leading space in format string
-------------------------------------+-------------------------------------
Reporter: mjo | Owner: Ashley Yakeley
Type: bug | Status: new
Priority: normal | Milestone:
Component: libraries | Version: 7.8.2
(other) | Keywords:
Resolution: | Operating System: Unknown/Multiple
Differential Revisions: | Type of failure: Incorrect result
Architecture: | at runtime
Unknown/Multiple | Test Case:
Difficulty: Unknown | Blocking:
Blocked By: |
Related Tickets: |
-------------------------------------+-------------------------------------
Comment (by mjo):
Replying to [comment:2 Ashley Yakeley]:
> Another alternative would be to drop skipping of leading and trailing
spaces. This would make the behaviour of the parsing functions more
predictable. However, the current behaviour has been there since time-1.1
from 2007, so programs that depend on it will fail with stricter
functions.
I assumed this was a bug because the behaviour changed between
time-1.4.0.1 and time-1.4.2. I've narrowed down the change to time-1.4.0.1
-> time-1.4.0.2. Maybe I'm misunderstanding what you wrote, but your
examples at least seem to parse fine with the older library.
{{{
$ ghc-pkg list | grep time
old-time-1.1.0.1
time-1.4.0.1
$ ghci
...
> parseTime defaultTimeLocale "%Q " " " :: Maybe LocalTime
Just 1970-01-01 00:00:00
> parseTime defaultTimeLocale "%k" " 8" :: Maybe LocalTime
Just 1970-01-01 08:00:00
}}}
The two examples in the description also both worked in earlier versions:
{{{
> parseTime defaultTimeLocale "%M " "15 " :: Maybe UTCTime
Just 1970-01-01 00:15:00 UTC
> parseTime defaultTimeLocale " %M" " 15" :: Maybe UTCTime
Just 1970-01-01 00:15:00 UTC
}}}
Maybe there was a bug in time <= 1.4.0.1 that prevented the spaces from
being skipped?
For what it's worth, my use case is in pickling/unpickling XML. The
package is now public at http://hackage.haskell.org/package/htsn-import. I
have a test case that basically says, if we unpickle some XML and then
repickle it, we should get what we started with. For that to work, the
leading/trailing space needs to be preserved (I don't control the XML so
I'm stuck with the spaces). I have a test case ensuring that, and with
time-1.4.0.1 it passes. Once I upgraded the time library along with ghc, I
noticed the failure.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9150#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list