Skip to content

trying to TODO-test GH 15419 (Cloning STDOUT loses encoding) #23531

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

Closed
wants to merge 1 commit into from

Conversation

zb226
Copy link

@zb226 zb226 commented Aug 3, 2025

I'm trying to contribute a TODO test following Karl Williamson's call, which was brought to my attention by Brain D. Foy over at reddit. I've run into issues and Brian suggested I'd open a PR here.


Hello, I'm trying to get my head around this in order to contribute. I don't know if it is a good or even valid issue to try, but I've picked GH 15419 for my first steps.

First, I've reproduced the actual problem - running this:

use strict;
use warnings;
binmode *STDOUT, ":encoding(utf8)";
open(my $copy, '>&', STDOUT);
print $copy "\x{11e}\n";

...with blead perl does indeed give the reported warning:

$ ./perl -Ilib ./gh15419.pl
Wide character in print at ./gh15419.pl line 5.
Ğ

Now if I add a new test into t/run/todo.pl like so:

TODO: {
    local $::TODO = 'GH 15419';
    my $results = fresh_perl(<<~'EOF', { stderr => 1 } );
        use strict;
        use warnings;
        binmode *STDOUT, ":encoding(utf8)";
        open(my $copy, '>&', STDOUT);
        print $copy "\x{11e}\n";
        EOF
    is($?, 0, "No assertion failure");
    is $results, "\x{11e}", "print returned the expected output";
    unlike $results, qr/Wide character in print/, "print did not warn about wide characters";
}

...I get:

ok 2 - No assertion failure # TODO GH 15419
not ok 3 - print returned the expected output # TODO GH 15419
# Failed test 3 - print returned the expected output at t/run/todo.t line 47
#      got "Ğ"
# expected "\x{11e}"
ok 4 - print did not warn about wide characters # TODO GH 15419

So there's two problems:

  1. Matching of the output fails. I get an unicode escape for the expectation, while the "got" value is printed as an true unicode character.
  2. The expected warning is not actually issued here. I guess this means running with t/test.pl somehow corrects for the behavior seen in the standalone script?

@jkeenan jkeenan changed the title trying to TODO-test GH 15419 (Cloning STDOUT looses encoding) trying to TODO-test GH 15419 (Cloning STDOUT loses encoding) Aug 3, 2025
@khwilliamson
Copy link
Contributor

I once took a seminar in graduate school. We were assigned several hard problems each week to work on, and then the next week had to show what progress we had made. Unbeknownst to us, sometimes they gave us problems that had never been solved by anyone. We students viewed this as unfair; the professors viewed it as, "put some fresh minds to work, and maybe a miracle will happen." Well, no miracle happened; I did come up with a novel proof of a theorem, but it wasn't any real advance. It was just a bit of glue binding together two existing theorems. (That I was unwilling to curtail my outside activities, like mountain climbing, to spend the significant amount of time required to publish the result in a journal convinced my advisor that I wasn't cut out for a life in academia; I myself didn't realize that until some time later.)

It looks to me like you inadvertently chose to start out with an unsolved problem. The person who wrote the original issue ticket is an expert on testing, and couldn't figure one out. I appreciate your willingness to contribute tests; and I suggest that it's unlikely a miracle is going to happen here, and maybe it would be best to try an easier one to begin with. I look forward to a p.r. for it (or them).

@zb226
Copy link
Author

zb226 commented Aug 5, 2025

Hello @khwilliamson, thanks for replying - and the nice anecdote :) I will close this PR and try again some other time!

@zb226 zb226 closed this Aug 5, 2025
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