Skip to content

(#11955) Refactor usages of IO.binread#363

Closed
joshcooper wants to merge 2 commits intopuppetlabs:2.7.xfrom
joshcooper:ticket/2.7.x/11955-binread
Closed

(#11955) Refactor usages of IO.binread#363
joshcooper wants to merge 2 commits intopuppetlabs:2.7.xfrom
joshcooper:ticket/2.7.x/11955-binread

Conversation

@joshcooper
Copy link
Contributor

Monkey patch IO.binread and IO.binwrite for older rubies and refactor usages of Puppet::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.

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.
@slippycheeze
Copy link
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?

@jeffmccune
Copy link
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.

@jeffmccune
Copy link
Contributor

Pull request #392 replaces this pull request.

@jeffmccune jeffmccune closed this Jan 23, 2012
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
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.

3 participants