Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not fail on .cabal files that contain Unicode (fixes #340) #341

Merged
merged 1 commit into from Mar 19, 2018

Conversation

sol
Copy link
Contributor

@sol sol commented Mar 19, 2018

No description provided.

Left msg -> liftIO $ do
hPutStrLn stderr "*** hpack output:"
hPutStrLn stderr hpackOutput
BS.hPutStrLn stderr hpackOutput
Copy link
Contributor Author

@sol sol Mar 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Outputting the plain ByteString here is not awesome and will result in gibberish if the locale is not set to UTF8. However, outputting the String as it was before results in an exception if the locale is e.g. c and the output contains Unicode code points > 127.

Not sure if I like the current code, but I also don't know any better options. We could do a show on hpackOutput first and then print this to stderr, but as the output is potentially very large that would not be awesome neither.

Any suggestions welcome!

buf <- withFile file ReadMode $ \ h -> do
hSetEncoding h utf8
hGetContents h >>= Exception.evaluate . force
let hash = printSHA256 (digestString (digestByName "sha256") buf)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

digestString is problematic, as it depends on the locale.

@sol
Copy link
Contributor Author

sol commented Mar 19, 2018

(fix for #340)

@sol
Copy link
Contributor Author

sol commented Mar 19, 2018

I was looking into adding a test case for this. But doing so is not trivial, as AFAICT Distribution.Nixpkgs.Haskell.PackageSourceSpec is currently not penetrated by the golden tests.

@peti For the same reason I assume that addressing your comment from 66cb4b6 alone would not detect #333 nor #340. In addition we would need to make sure that Distribution.Nixpkgs.Haskell.PackageSourceSpec is penetrated by the tests.

@peti
Copy link
Member

peti commented Mar 19, 2018

Personally, I'd prefer a path where Distribution.Nixpkgs.Haskell.PackageSourceSpec is removed from the source code and never to be seen again. That code is a bona fide testing and maintenance nightmare. I'll do some drastic refactoring in the future ...

Anyhow, thank you for the quick fix!

@peti peti merged commit 41f1b64 into NixOS:master Mar 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants