Closed dalang closed 10 years ago
I don't think this is a bug in windows-pr. I mean, buf is just a string, so calling buf.strip should not raise any kind of error. Very strange.
The output for buf that you posted looks like 2 strings. Is that supposed to be one long string? Does it cause any sort of issue if you just copy/paste that into irb and call .strip on it?
I'm also curious what puppet is using that requires windows-pr as I've moved most libraries over to ffi.
Here is a mistake in my last post, I duplicated the buf output, indeed it is a single string.
On Mac OSX 10.9, I copy/paste it into irb and call .strip on it
"\317\265\315\263\325\322\262\273\265\275\326\270\266\250\265\304\316\304\274\376\241\243"
ArgumentError: invalid byte sequence in UTF-8 from (irb):5:in
strip'`On Ubuntu 12.04, the same operation but outputs changes:
"\317\265\315\263\325\322\262\273\265\275\326\270\266\250\265\304\316\304\274\376\241\243"
"\xCF\xB5\xCD\xB3\xD5\xD2\xB2\xBB\xB5\xBD\xD6\xB8\xB6\xA8\xB5\xC4\xCE\xC4\xBC\xFE\xA1\xA3"
I agree with you that's not a bug in windows-pr. But there is not doubt something wrong make the error happen. I have no idea how to get rid of it, could you give me a few hints?
It seems that your code page is 936 (Simplified Chinese). The current windows-pr is based on US-ASCII code page.
The line 449 of lib/windows/error.rb
buf.strip
should be modified as
if RUBY_VERSION < '1.9.0'
buf.strip
else
buf.force_encoding(Encoding.default_external).strip
end
Bingo. Thanks to @phasis68 for pointing out the reason and giving a solution.
Windows 2008 Server R2, I worked on, use Code page 936, which is Microsoft's character encoding for Simplified Chinese.
The value of Encoding.default_external
is Encoding::GBK
in my environment.
This solution resolve my problem perfectly.
I encountered this error when use puppet 3.3.2. It contains windows-pr 1.2.2. Each time I run puppet agent, I found error info as below:
I add 'p buf' in to #get_last_error and get the following output:
my puppet agent runs well if I change the
buf.strip
tobuf
in #get_last_error. Maybe it is a bug in windows-pr 1.2.2.