open(my $dup, "<&", $fh) (and >&, <&=, >&=) fails with "Bad file descriptor" when $fh is a mocked filehandle.
Reproduce
use Test::MockFile ();
my $mock = Test::MockFile->file("/tmp/test", "hello\n");
open(my $fh, "<", "/tmp/test") or die;
open(my $dup, "<&", $fh) or die "dup: $!"; # Dies: Bad file descriptor
Cause
The <& mode is not in __open's supported mode list (> < >> +< +> +>>), so it falls through to CORE::open. Since mocked handles have synthetic filenos (FILENO dies), the kernel-level dup fails.
Fix
PR #424 detects dup modes early in __open and creates a new tied handle sharing the same mock data when the source handle is mocked.
open(my $dup, "<&", $fh)(and>&,<&=,>&=) fails with "Bad file descriptor" when$fhis a mocked filehandle.Reproduce
Cause
The
<&mode is not in__open's supported mode list (> < >> +< +> +>>), so it falls through toCORE::open. Since mocked handles have synthetic filenos (FILENO dies), the kernel-level dup fails.Fix
PR #424 detects dup modes early in
__openand creates a new tied handle sharing the same mock data when the source handle is mocked.