-
Notifications
You must be signed in to change notification settings - Fork 209
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
Test failure on 5.17.6 #870
Comments
Having looked at the code in Plack's It looks like a normal filehandle opened that way won't be blessed by default: #!/usr/bin/perl
use strict;
my $foo = "Foo bar";
open my $fh, "<", \$foo
or die "Failed to open - $!";;
say "fh is a " . ref $fh;
if ($fh->can('read')) {
say "Yep, can read()";
} else {
say "No read()";
} gives me the following:
So, it would seem that that code in Plack, returning a straightforward filehandle, contravenes the bit of the Plack docs I quoted earlier. I'll double check this is actually the case, then report it. |
It would appear the problem is that for whatever reason, Just where exactly its failing is hard to work out. ie: it doesn't matter if its blessed or not, if its a filehandle at all, then it would work, ( Because of how IO::Handle autoloading works, all filehandles behave like blessed objects ). Just to make sure, I placed the following code in my $handle;
$handle = $self->input_handle;
if ( Scalar::Util::blessed( $handle ) ){
$rc = $handle->read( $buffer, $readlen );
} else {
$rc = read( $handle, $buffer, $readlen );
}
The problem is of course, The problem is to work out /why/ the glob got wrongly stringified in $ENV. |
If you want to catch the error a little earlier: Dancer/Request.pm sub new {
my ($self, @args) = @_;
if (@args == 1) {
@args = ('env' => $args[0]);
Dancer::Deprecation->deprecated(
fatal => 1,
feature => 'Calling Dancer::Request->new($env)',
version => 1.3059,
reason => 'Please use Dancer::Request->new( env => $env ) instead',
);
}
if( @args == 2 and $args[0] eq 'env' ){
for my $check ( qw( psgi.input PSGI.INPUT ) ) {
if( exists $args[1]->{$check} and not ref $args[1]->{$check} ) {
require Carp;
Carp::confess( "Non-Reference $check == " . $args[1]->{$check} );
}
}
}
$self->SUPER::new(@args);
} This helps a bit, |
Seems the problem is using the magical variable
use strict;
use warnings;
my %hash;
{
my $content = "hello";
open my $fh, '<', \$content;
$ENV{'foo'} = $fh;
$hash{'foo'} = $fh;
}
print "ENV{'foo'} is " . ( ref $ENV{'foo'} ? '' : 'not ') . "a ref\n";
print "hash{'foo'} is " . ( ref $hash{'foo'} ? '' : 'not ') . "a ref\n";
So the only way to solve this problem is stop using the magical variable %ENV to pass references around. |
Perl 5.17.3+ changes behaviour of `%ENV` so values are also stringified. This change aims to solve that ( gh PerlDancer#870 ) by replacing %ENV based code with a passed around local hashref, that is passed as the last parameter to `new_for_request()` instead of relying on the data being passed around via `%ENV`.
Fixed by #874, closing. |
Perl 5.17.3+ changes behaviour of `%ENV` so values are also stringified. This change aims to solve that ( gh PerlDancer#870 ) by replacing %ENV based code with a passed around local hashref, that is passed as the last parameter to `new_for_request()` instead of relying on the data being passed around via `%ENV`. Conflicts: lib/Dancer/Request.pm lib/Dancer/Test.pm
In checking whether our tests will get bitten by the upcoming hash key ordering changes, I just tried building Dancer using 5.17.6, and the tests failed with:
The line in question is:
$self->input_handle()
looks like:The PSGI docs say that the
psgi.input
env var has the following to say:It's entirely possible that the problem lies with PSGI, not Dancer, but it needs investigation.
The text was updated successfully, but these errors were encountered: