-
Notifications
You must be signed in to change notification settings - Fork 29
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
08-screen.t fails with PERL_UNICODE and 5.22.1 #32
Comments
From [email protected] (@madsen) on 2016-01-13 05:39:29:
|
From [email protected] (@karenetheridge) on 2016-01-13 06:00:55: relevant: http://www.dagolden.com/index.php/1771/why-perl_unicode-makes-me-sad/ |
From [email protected] (@madsen) on 2016-01-13 06:09:39: On Wed, Jan 13, 2016 12:00:55 AM, ETHER wrote:
Possibly, although I don't use D, just S(tandard IO handles) and A(rgv). (L means that SA applies only if the locale is UTF-8, which is why LANG=C makes the test pass.) |
From [email protected] (@autarch) on 2016-01-13 06:16:27: On Wed Jan 13 01:09:39 2016, CJM wrote:
It'd probably the S causing the problem. That said, I don't think running arbitrary tests with env vars that change the Perl interpreter's behavior should be expected to work. |
From [email protected] (@madsen) on 2016-01-13 06:26:59: As xdg mentions in that article, it's useful to test modules the way they'll be used. I'm of the opinion that a test should clean up its environment if it's doing something tricky that breaks if certain variables are set. In this case, the attached patch will work. |
From [email protected] (@dagolden) on 2016-01-13 15:08:48: On Wed Jan 13 01:16:27 2016, DROLSKY wrote:
People put all sorts of stuff in their environment, so tests ought to reset any that cause problems. This is no different than PERL5LIB, PERL5OPT, etc. Or setting up a temporary HOME directly to avoid automatically picking up config files. PERL_UNICODE is just a particularly uncommon one. :-/ |
From [email protected] (@autarch) on 2016-01-13 15:11:05: On Wed Jan 13 10:08:48 2016, DAGOLDEN wrote:
This is something that should be done in Test::More or something like that, then. Do we really expect every CPAN module to add boilerplate to every test to reset every possible env var that someone might set? I'm of course fine with patching this test now that we know the issue and the simple fix, but as a general rule I think that if you run tests with random perl env vars set, you should expect random failures. |
From [email protected] (@karenetheridge) on 2016-01-13 17:50:36: On 2016-01-13 07:11:05, DROLSKY wrote:
Having Test::More reset the variables entirely defeats the point of This isn't a random variable -- it's one that affects the behaviour of I see it as similar to making a module work in various locales, or with (I'm also now pondering which of my modules do interesting things with filehandles |
From [email protected] (@autarch) on 2016-01-13 21:16:21: On Wed Jan 13 12:50:36 2016, ETHER wrote:
Good point, except that this patch explicitly breaks your ability to test this module with the env var in question! In fact, it will mislead you into thinking that this will work when it fact it will not.
There's a limit to how many different environments a module can be expected to work in. An environment that globally messes with every single filehandle is likely to break a lot of CPAN modules. This seems like one of those "use at your own risk or with lots of testing things". That said, if someone wants to patch the module (not the test) to make it actually do the right thing here, I would happily apply such a patch. I'm not sure exactly what the right thing is or why it breaks though. I'm guessing there some sort of double encoding issue going on. Also, this is testing a "utf8" option that you would want to not pass if you set this global env var in all your code. So maybe just a doc patch? |
From [email protected] (@mauke) on 2016-02-27 16:52:21: On Wed Jan 13 16:16:21 2016, DROLSKY wrote:
I don't know about this problem but there's a kind of similar bug in DBI: That one is caused by sending binary data over STDIN/STDOUT without calling binmode() on them. Which breaks with PERL_UNICODE=S because that makes the STD* handles start out as ":utf8". |
The STD{IN,OUT,ERR} default handles start out in some unspecified (platform-specific) text encoding. The 'utf8' option of Log::Dispatch::Screen manually encodes the logged messages as bytes in UTF-8 format before writing them to the output handle. Thus, by default, the UTF-8 bytes get re-encoded by whatever the native text encoding is on the platform. The correct way to handle this is to either not set 'utf8' (and rely on the encoding layer of the handle) or set 'utf8' and call binmode() on the handle (or otherwise apply a ':raw' layer) to ensure that bytes are written as is (without further re-encoding). Fixes houseabsolute#32.
Eight years later ...Log::Dispatch tests are still failing (and writing mojibake to the screen):
The underlying cause of the problem is now understood: The test writes binary data to a file handle (STDOUT/STDERR) without switching it to binary mode first (with Meanwhile, the DBI issue I mentioned above did turn out to be a very similar problem. A patch adding the missing
Hard to do without breaking the existing documented behavior:
Morally, the right thing to do is to call
It's an environment variable, so people set it in their environment, not in code. In particular, this issue affects third-party applications that use Log::Dispatch internally, not just my own code. Would you be willing to accept a patch that calls |
Migrated from rt.cpan.org #111143 (status was 'open')
Requestors:
Attachments:
From [email protected] (@madsen) on 2016-01-13 05:38:40:
With Perl 5.22.1, LANG=en_US.UTF-8, and PERL_UNICODE=SAL, 08-screen.t fails. It succeeds if I set either LANG=C or PERL_UNICODE=0.
With Perl 5.20.2, the test passes even with PERL_UNICODE=SAL.
I've attached the result of running
perl5.22.1 t/00-report-prereqs.t &>/tmp/00-report-prereqs.txt
along with the results of 00-report-prereqs.t for both 5.20.2 and 5.22.1.
The text was updated successfully, but these errors were encountered: