Skip Menu |

This queue is for tickets about the IO-Callback CPAN distribution.

Report information
The Basics
Id: 132961
Status: resolved
Priority: 0/
Queue: IO-Callback

People
Owner: Nobody in particular
Requestors: alti [...] kribrum.ru
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: A call to the stat method throws an exception
Date: Thu, 09 Jul 2020 01:52:42 +0300
To: bug-IO-Callback [...] rt.cpan.org
From: alti [...] kribrum.ru
When calling the stat method, an exception occurs Can't use an undefined value as a SCALAR reference at ....../IO/String.pm line 358. The reason is that in the basic IO::String, the buffer is called 'buf' (all characters are lowercase), and in IO::Callback the buffer is called 'Buf' (first character in upper case). Modules: p5-IO-String-1.08 p5-IO-Callback-1.12 Perl: This is perl 5, version 30, subversion 3 (v5.30.3) built for amd64-freebsd-thread-multi System: FreeBSD riga 12.1-RELEASE-p2 FreeBSD 12.1-RELEASE-p2 GENERIC amd64 Code showing the problem: use IO::Callback; my $count = 0; my $fh = IO::Callback->new('<', sub {return if ++$count > 10;return "foo\n";},[]); print $fh->stat;
Hmm... two possible solutions... 1. Set $fh->{buf} = $fh->{Buf} when the handle is opened, and ensure $fh->{buf} is deleted when the handle is closed. Or 2. Change $fh->{Buf} to $fh->{buf} everywhere. Probably lowercase the other keys too for consistency. I'm thinking the second solution is probably better, but it might break subclasses, so could warrant a bump to version 2.00.
Subject: Re: [rt.cpan.org #132961] A call to the stat method throws an exception
Date: Fri, 17 Jul 2020 14:06:04 +0300
To: bug-IO-Callback [...] rt.cpan.org
From: Alexander Gorlov <alti [...] ashmanov.com>
The second way really looks more correct, but there is a third way (I used it myself as a quick fix), replace the stat method so that it does not call the stat method from the IO::String module. This does not break compatibility with previously created submodules. This is almost a complete copy-paste of the stat method from the IO::String module, I don't really like this approach, but it also solves the problem. I originally used a replacement like this (about the size, I wrote to you earlier): sub stat {   my $self = shift;   return unless $self->opened;   return 1 unless wantarray;   my $len = *$self->{size}//0;   return (      undef, undef,  # dev, ino      0666,          # filemode      1,             # links      "$>",          # user id      "$)",          # group id      undef,         # device id      $len,          # size      undef,         # atime      undef,         # mtime      undef,         # ctime      512,           # blksize      (int(($len+511)/512) || 1)  # blocks   ); } If it is possible to release version 2.00 with fixes and new features, then I like the new version more. 17.07.2020 13:30, Toby Inkster via RT пишет: Show quoted text
> Hmm... two possible solutions... > > 1. Set $fh->{buf} = $fh->{Buf} when the handle is opened, and ensure $fh->{buf} is deleted when the handle is closed. > > Or > > 2. Change $fh->{Buf} to $fh->{buf} everywhere. Probably lowercase the other keys too for consistency. > > I'm thinking the second solution is probably better, but it might break subclasses, so could warrant a bump to version 2.00.
Fixed in 2.00.