(#11955) Refactor usages of IO.binread#363
Closed
joshcooper wants to merge 2 commits intopuppetlabs:2.7.xfrom
Closed
(#11955) Refactor usages of IO.binread#363joshcooper wants to merge 2 commits intopuppetlabs:2.7.xfrom
joshcooper wants to merge 2 commits intopuppetlabs:2.7.xfrom
Conversation
binread and binwrite are only available in ruby 1.9, so adding these for older ruby versions.
Previously, I had created a utility method `Puppet::Util.binread`, since `IO.binread` was added in ruby 1.9. This commit monkey patches the method, if it's not defined, to make the transition to ruby 1.9 seamless. And while I was at it, I add the corresponding `IO.binwrite` method. The motivation for these methods is that, in general, we should always be using binary mode when performing file I/O. However, text mode is the default on Windows, and using text mode can corrupt binary data, e.g. executables. So use binary mode, unless you know what text mode is and why you need to use it.
Contributor
|
Hey, Josh. I would love to merge this, but looks like other changes broke the direct merge. Can you rebase it, since I don't have Win32 to test that I didn't mess something up? |
Contributor
|
I'm in the process of rebasing this pull request. I'll update the ticket and the pull request once it's ready to go. |
Contributor
|
Pull request #392 replaces this pull request. |
hlindberg
pushed a commit
to hlindberg/puppet
that referenced
this pull request
Oct 16, 2014
…ew-index-for-fact-nodes (maint) Add new fact-nodes endpoint to v4, and re-order sensibly
melissa
pushed a commit
to melissa/puppet
that referenced
this pull request
Mar 30, 2018
(PCP-232) Acceptance - ensure pxp-agent is usable after restarting host
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Monkey patch
IO.binreadandIO.binwritefor older rubies and refactor usages ofPuppet::Util.binread.The motivation for these methods is that, in general, we should most often be using binary mode when performing file I/O. However, text mode is the default on Windows, and using text mode can corrupt binary data, e.g. executables. So use binary mode, unless you know what text mode is and why you need to use it.