<commit_before>my class IO::Path { ... }
my class IO::Special { ... }

my class IO::Handle does IO {
    has $.path;
    has $!PIO;
    has int $.ins;
    has $.chomp is rw = Bool::True;
    has $.nl    = "\n";
    has int $!pipe;

    method pipe(IO::Handle:D: |c) {
        self.open(:p, |c);
    }

    method open(IO::Handle:D:
      :$r is copy,
      :$w is copy,
      :$rw,
      :$a,
      :$p,
      :$bin,
      :$chomp = True,
      :$enc   = 'utf8',
      :$nl    = "\n",
    ) {

        if $!path eq '-' {
            $!path =
              IO::Special.new(:what( $w ?? << <STDOUT> >> !! << <STDIN> >> ));
        }

        if nqp::istype($!path,IO::Special) {
            my $what := $!path.what;
            if $what eq '<STDIN>' {
                $!PIO := nqp::getstdin();
            }
            elsif $what eq '<STDOUT>' {
                $!PIO := nqp::getstdout();
            }
            elsif $what eq '<STDERR>' {
                $!PIO := nqp::getstderr();
            }
            else {
                die "Don't know how to open '$_' especially";
            }
            $!chomp = $chomp;
            nqp::setencoding($!PIO, NORMALIZE_ENCODING($enc)) unless $bin;
            return self;
        }

        fail (X::IO::Directory.new(:$!path, :trying<open>))
          if $!path.e && $!path.d;
        $r = $w = True if $rw;

        if $p {
            DEPRECATED('pipe($path,...)',|<2015.06 2015.09>,:what(':p for pipe'));
            $!pipe = 1;

            my str $errpath;
            $!PIO := nqp::openpipe(
              nqp::unbox_s($!path.Str),
              nqp::unbox_s($*CWD.Str),
              CLONE-HASH-DECONTAINERIZED(%*ENV),
              $errpath,
            );
        }
        else {
            my $mode =  $w ?? 'w' !! ($a ?? 'wa' !! 'r' );
            # TODO: catch error, and fail()
            $!PIO := nqp::open(
              nqp::unbox_s($!path.abspath),
              nqp::unbox_s($mode),
            );
        }

        $!chomp = $chomp;
        nqp::setinputlinesep($!PIO, nqp::unbox_s($!nl = $nl));<commit_msg>Quick fix for #125454<commit_after>my class IO::Path { ... }
my class IO::Special { ... }

my class IO::Handle does IO {
    has $.path;
    has $!PIO;
    has int $.ins;
    has $.chomp is rw = Bool::True;
    has $.nl    = "\n";
    has int $!pipe;

    method pipe(IO::Handle:D: |c) {
        self.open(:p, :nodepr, |c);
    }

    method open(IO::Handle:D:
      :$r is copy,
      :$w is copy,
      :$rw,
      :$a,
      :$p,
      :$bin,
      :$chomp = True,
      :$enc   = 'utf8',
      :$nl    = "\n",
      :$nodepr,
    ) {

        if $!path eq '-' {
            $!path =
              IO::Special.new(:what( $w ?? << <STDOUT> >> !! << <STDIN> >> ));
        }

        if nqp::istype($!path,IO::Special) {
            my $what := $!path.what;
            if $what eq '<STDIN>' {
                $!PIO := nqp::getstdin();
            }
            elsif $what eq '<STDOUT>' {
                $!PIO := nqp::getstdout();
            }
            elsif $what eq '<STDERR>' {
                $!PIO := nqp::getstderr();
            }
            else {
                die "Don't know how to open '$_' especially";
            }
            $!chomp = $chomp;
            nqp::setencoding($!PIO, NORMALIZE_ENCODING($enc)) unless $bin;
            return self;
        }

        fail (X::IO::Directory.new(:$!path, :trying<open>))
          if $!path.e && $!path.d;
        $r = $w = True if $rw;

        if $p {
            DEPRECATED('pipe($path,...)',|<2015.06 2015.09>,:what(':p for pipe')) unless $nodepr;
            $!pipe = 1;

            my str $errpath;
            $!PIO := nqp::openpipe(
              nqp::unbox_s($!path.Str),
              nqp::unbox_s($*CWD.Str),
              CLONE-HASH-DECONTAINERIZED(%*ENV),
              $errpath,
            );
        }
        else {
            my $mode =  $w ?? 'w' !! ($a ?? 'wa' !! 'r' );
            # TODO: catch error, and fail()
            $!PIO := nqp::open(
              nqp::unbox_s($!path.abspath),
              nqp::unbox_s($mode),
            );
        }

        $!chomp = $chomp;
        nqp::setinputlinesep($!PIO, nqp::unbox_s($!nl = $nl));
{'fraction_non_alphanumeric': 0.19283681214421253, 'fraction_numerical': 0.008064516129032258, 'mean_word_length': 1.3427777777777778, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3268315', 'n_tokens_mistral': 1538, 'n_tokens_neox': 1467, 'n_words': 304}