Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[perl #25160] ':flock' not recognized unless it's first

0 views
Skip to first unread message

Mark-Jason Dominus

unread,
Jan 20, 2004, 7:39:23 AM1/20/04
to bugs-bi...@netlabs.develooper.com
# New Ticket Created by Mark-Jason Dominus
# Please include the string: [perl #25160]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=25160 >

This is a bug report for perl from m...@plover.com,
generated with the help of perlbug 1.34 running under perl v5.8.0.


-----------------------------------------------------------------
[Please enter your report here]

plover% bash-2.04$ perl -le 'use Fcntl ":flock"; print "OK"'
OK

plover% perl -le 'use Fcntl ":flock", "O_RDONLY"; print "OK"'
OK

plover% perl -le 'use Fcntl "O_RDONLY", ":flock"; print "OK"'
":flock" is not exported by the Fcntl module
Can't continue after import errors at -e line 1
BEGIN failed--compilation aborted at -e line 1.

[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
category=library
severity=medium
---
Site configuration information for perl v5.8.0:

Configured by mjd at Thu Apr 17 11:57:37 EDT 2003.

Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration:
Platform:
osname=linux, osvers=2.4.2-2, archname=i586-linux
uname='linux plover.com 2.4.2-2 #1 sun apr 8 19:37:14 edt 2001 i586 unknown '
config_args='-des'
hint=previous, useposix=true, d_sigaction=define
usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='cc', ccflags ='-fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm',
optimize='-O2',
cppflags='-fno-strict-aliasing -I/usr/local/include -I/usr/include/gdbm -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm'
ccversion='', gccversion='2.96 20000731 (Red Hat Linux 7.1 2.96-81)', gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
alignbytes=4, prototype=define
Linker and Libraries:
ld='cc', ldflags =' -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib
libs=-lnsl -lndbm -lgdbm -ldl -lm -lc -lcrypt -lutil
perllibs=-lnsl -ldl -lm -lc -lcrypt -lutil
libc=/lib/libc-2.2.2.so, so=so, useshrplib=false, libperl=libperl.a
gnulibc_version='2.2.4'
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:

---
@INC for perl v5.8.0:
/usr/local/lib/perl5/5.8.0/i586-linux
/usr/local/lib/perl5/5.8.0
/usr/local/lib/perl5/site_perl/5.8.0/i586-linux
/usr/local/lib/perl5/site_perl/5.8.0
/usr/local/lib/perl5/site_perl/5.7.3
/usr/local/lib/perl5/site_perl/5.7.2
/usr/local/lib/perl5/site_perl/5.6.1
/usr/local/lib/perl5/site_perl/5.6.0
/usr/local/lib/perl5/site_perl
.

---
Environment for perl v5.8.0:
HOME=/home/mjd
LANG=C
LANGUAGE (unset)
LD_LIBRARY_PATH=/lib:/usr/lib:/usr/X11R6/lib
LOGDIR (unset)
PATH=/home/mjd/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/usr/games:/sbin:/usr/sbin:/usr/local/bin/X11R6:/usr/local/bin/mh:/data/mysql/bin:/usr/local/bin/pbm:/usr/local/bin/ezmlm:/home/mjd/TPI/bin:/usr/local/teTeX/bin:/usr/local/mysql/bin
PERL_BADLANG (unset)
SHELL=/bin/bash

Steve Hay

unread,
Jan 20, 2004, 9:54:27 AM1/20/04
to perl5-...@perl.org, bugs-bi...@netlabs.develooper.com
Mark-Jason Dominus (via RT) wrote:

> plover% bash-2.04$ perl -le 'use Fcntl ":flock"; print "OK"'
> OK
>
> plover% perl -le 'use Fcntl ":flock", "O_RDONLY"; print "OK"'
> OK
>
> plover% perl -le 'use Fcntl "O_RDONLY", ":flock"; print "OK"'
> ":flock" is not exported by the Fcntl module
> Can't continue after import errors at -e line 1
> BEGIN failed--compilation aborted at -e line 1.
>
>

Exporter's manpage says:

"If the first entry in an import list begins with !, : or / then the
list is treated as a series of specifications which either add to or
delete from the list of names to import."

By implication, the special treatment of the export tags (names
beginning with a colon) doesn't apply if they don't appear first in the
import list.

Whether or not that's what people actually _expect_ (i.e. without having
read the manpage ;) is another matter.

- Steve

------------------------------------------------
Radan Computational Ltd.

The information contained in this message and any files transmitted with it are confidential and intended for the addressee(s) only. If you have received this message in error or there are any problems, please notify the sender immediately. The unauthorized use, disclosure, copying or alteration of this message is strictly forbidden. Note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of Radan Computational Ltd. The recipient(s) of this message should check it and any attached files for viruses: Radan Computational will accept no liability for any damage caused by any virus transmitted by this email.

Mark Jason Dominus

unread,
Jan 21, 2004, 8:32:47 AM1/21/04
to perl5-...@perl.org, perlbug-...@perl.org
Steve Hay <stev...@uk.radan.com>:

> Mark-Jason Dominus (via RT) wrote:
>
> > plover% perl -le 'use Fcntl "O_RDONLY", ":flock"; print "OK"'
> > ":flock" is not exported by the Fcntl module
> > Can't continue after import errors at -e line 1
> > BEGIN failed--compilation aborted at -e line 1.
> >
> >
> Exporter's manpage says:
>
> "If the first entry in an import list begins with !, : or / then the
> list is treated as a series of specifications which either add to or
> delete from the list of names to import."
>
> By implication, the special treatment of the export tags (names
> beginning with a colon) doesn't apply if they don't appear first in the
> import list.

Your conclusion is not correct, because in

use POSIX qw(:errno_h :termios_h !TCSADRAIN !/^EXIT/);

':termios_h' is treated specially even though it does not appear first.


More to the point, I wonder what would be the possible disadvantage of
extending the special treatment of ':' and '!' items to those that
appear anywhere in the list. I understood the ':errno_h' here to mean
'please give me all of the errno.h items'. I see no reason why it
should mean this under some circumstances, but have a different
meaning under other circumstances.

If modules wanted to export a lot of symbols that really did begin
with ':', it might make sense. But they do not, so it doesn't.
Modules never export symbols that begin with ':' or '!'.

Am I missing something here?

Gisle Aas

unread,
Jan 21, 2004, 8:53:11 AM1/21/04
to Mark Jason Dominus, perl5-...@perl.org, perlbug-...@perl.org
Mark Jason Dominus <m...@plover.com> writes:

> Am I missing something here?

Allowing ':tag' everywhere makes the implementation of Exporter::Heavy
even more heavy. Currently $imports[0] =~ m#^[/!:]# is used as a
cheap test for whether tag processing is needed.

Other than that I don't see any problem.

Regards,
Gisle

Steve Hay

unread,
Jan 21, 2004, 8:56:20 AM1/21/04
to Mark Jason Dominus, perl5-...@perl.org, perlbug-...@perl.org
Mark Jason Dominus wrote:

>Steve Hay <stev...@uk.radan.com>:
>
>
>>Mark-Jason Dominus (via RT) wrote:
>>
>>
>>
>>> plover% perl -le 'use Fcntl "O_RDONLY", ":flock"; print "OK"'
>>> ":flock" is not exported by the Fcntl module
>>> Can't continue after import errors at -e line 1
>>> BEGIN failed--compilation aborted at -e line 1.
>>>
>>>
>>>
>>>
>>Exporter's manpage says:
>>
>>"If the first entry in an import list begins with !, : or / then the
>>list is treated as a series of specifications which either add to or
>>delete from the list of names to import."
>>
>>By implication, the special treatment of the export tags (names
>>beginning with a colon) doesn't apply if they don't appear first in the
>>import list.
>>
>>
>
>Your conclusion is not correct, because in
>
> use POSIX qw(:errno_h :termios_h !TCSADRAIN !/^EXIT/);
>
>':termios_h' is treated specially even though it does not appear first.
>

Yes, sorry - I phrased it badly. Exporter's manpage itself is correct
in what it says, though.

In order to have the :tags treated specially, the _first_ entry must
begin with a colon. The first entry in your POSIX example (:errno_h)
does begin with a colon, hence you get the special treatment (even for
later items). The first entry in your "faulty" Fcntl example (O_RDONLY)
does not, so you don't get the special treatment.

>
>
>More to the point, I wonder what would be the possible disadvantage of
>extending the special treatment of ':' and '!' items to those that
>appear anywhere in the list.
>

The special treatment _does_ extend to other items in the list, but only
if the _first_ item begins with a colon.

> I understood the ':errno_h' here to mean
>'please give me all of the errno.h items'. I see no reason why it
>should mean this under some circumstances, but have a different
>meaning under other circumstances.
>
>If modules wanted to export a lot of symbols that really did begin
>with ':', it might make sense. But they do not, so it doesn't.
>Modules never export symbols that begin with ':' or '!'.
>

I agree, I think. The special handling of colons etc should be applied
(to all items in the list) even when the first item doesn't begin with
one of the special characters.

H.Merijn Brand

unread,
Jan 21, 2004, 10:40:20 AM1/21/04
to Gisle Aas, Perl 5 Porters

like this?

--- lib/Exporter/Heavy.pm.org 2004-01-21 16:32:04.000000000 +0100
+++ lib/Exporter/Heavy.pm 2004-01-21 16:34:24.000000000 +0100
@@ -69,7 +69,7 @@ sub heavy_export {
$cache_is_current = 1;
}

- if ($imports[0] =~ m#^[/!:]#){
+ if (join ("\n", @imports) =~ m{\n[/!:]}) {
my $tagsref = \%{"${pkg}::EXPORT_TAGS"};
my $tagdata;
my %imports;

> Regards,
> Gisle

--
H.Merijn Brand Amsterdam Perl Mongers (http://amsterdam.pm.org/)
using perl-5.6.1, 5.8.0, & 5.9.x, and 806 on HP-UX 10.20 & 11.00, 11i,
AIX 4.3, SuSE 8.2, and Win2k. http://www.cmve.net/~merijn/
http://archives.develooper.com/daily...@perl.org/ per...@perl.org
send smoke reports to: smokers...@perl.org, QA: http://qa.perl.org

Gisle Aas

unread,
Jan 21, 2004, 11:32:12 AM1/21/04
to H.Merijn Brand, Perl 5 Porters
"H.Merijn Brand" <h.m....@hccnet.nl> writes:

> On Wed 21 Jan 2004 14:53, Gisle Aas <gi...@ActiveState.com> wrote:
> > Mark Jason Dominus <m...@plover.com> writes:
> >
> > > Am I missing something here?
> >
> > Allowing ':tag' everywhere makes the implementation of Exporter::Heavy
> > even more heavy. Currently $imports[0] =~ m#^[/!:]# is used as a
> > cheap test for whether tag processing is needed.
> >
> > Other than that I don't see any problem.
>
> like this?
>
> --- lib/Exporter/Heavy.pm.org 2004-01-21 16:32:04.000000000 +0100
> +++ lib/Exporter/Heavy.pm 2004-01-21 16:34:24.000000000 +0100
> @@ -69,7 +69,7 @@ sub heavy_export {
> $cache_is_current = 1;
> }
>
> - if ($imports[0] =~ m#^[/!:]#){
> + if (join ("\n", @imports) =~ m{\n[/!:]}) {
> my $tagsref = \%{"${pkg}::EXPORT_TAGS"};
> my $tagdata;
> my %imports;

Is that faster than the more obvious:

if (grep m#^[/!:]#, @imports) {
...
}

Also I don't think your version will recognize ":foo" in the first
@import element. You might want your RE to be m{^[/!:]}m instead.

Regards,
Gisle

H.Merijn Brand

unread,
Jan 21, 2004, 11:35:18 AM1/21/04
to Gisle Aas, Perl 5 Porters
On Wed 21 Jan 2004 17:32, Gisle Aas <gi...@ActiveState.com> wrote:
> "H.Merijn Brand" <h.m....@hccnet.nl> writes:
>
> > On Wed 21 Jan 2004 14:53, Gisle Aas <gi...@ActiveState.com> wrote:
> > > Mark Jason Dominus <m...@plover.com> writes:
> > >
> > > > Am I missing something here?
> > >
> > > Allowing ':tag' everywhere makes the implementation of Exporter::Heavy
> > > even more heavy. Currently $imports[0] =~ m#^[/!:]# is used as a
> > > cheap test for whether tag processing is needed.
> > >
> > > Other than that I don't see any problem.
> >
> > like this?
> >
> > --- lib/Exporter/Heavy.pm.org 2004-01-21 16:32:04.000000000 +0100
> > +++ lib/Exporter/Heavy.pm 2004-01-21 16:34:24.000000000 +0100
> > @@ -69,7 +69,7 @@ sub heavy_export {
> > $cache_is_current = 1;
> > }
> >
> > - if ($imports[0] =~ m#^[/!:]#){
> > + if (join ("\n", @imports) =~ m{\n[/!:]}) {
> > my $tagsref = \%{"${pkg}::EXPORT_TAGS"};
> > my $tagdata;
> > my %imports;
>
> Is that faster than the more obvious:
>
> if (grep m#^[/!:]#, @imports) {

boy, am I glad I did not submit that proposal :)

I still don't like # as re sep now that we have a much better readable {}

> ...
> }
>
> Also I don't think your version will recognize ":foo" in the first
> @import element. You might want your RE to be m{^[/!:]}m instead.
>
> Regards,
> Gisle

--

H.Merijn Brand

unread,
Jan 21, 2004, 4:35:51 PM1/21/04
to Gisle Aas, Perl 5 Porters
On Wed 21 Jan 2004 17:32, Gisle Aas <gi...@ActiveState.com> wrote:
> "H.Merijn Brand" <h.m....@hccnet.nl> writes:
>
> > On Wed 21 Jan 2004 14:53, Gisle Aas <gi...@ActiveState.com> wrote:
> > > Mark Jason Dominus <m...@plover.com> writes:
> > >
> > > > Am I missing something here?
> > >
> > > Allowing ':tag' everywhere makes the implementation of Exporter::Heavy
> > > even more heavy. Currently $imports[0] =~ m#^[/!:]# is used as a
> > > cheap test for whether tag processing is needed.
> > >
> > > Other than that I don't see any problem.
> >
> > like this?
> >
> > --- lib/Exporter/Heavy.pm.org 2004-01-21 16:32:04.000000000 +0100
> > +++ lib/Exporter/Heavy.pm 2004-01-21 16:34:24.000000000 +0100
> > @@ -69,7 +69,7 @@ sub heavy_export {
> > $cache_is_current = 1;
> > }
> >
> > - if ($imports[0] =~ m#^[/!:]#){
> > + if (join ("\n", @imports) =~ m{\n[/!:]}) {
> > my $tagsref = \%{"${pkg}::EXPORT_TAGS"};
> > my $tagdata;
> > my %imports;
>
> Is that faster than the more obvious:

only if there is a large list. grep will match against every item, where join
(either with join or with {$"="\n";"@imports"=~m{...}}) could stop after the
first match, and a concat is cheaper than a match. Now the chance on having
huge import lists is rather small, and it documents much better. Thanks.

> if (grep m#^[/!:]#, @imports) {
> ...

Test cases welcome still

Change 22192 by merijn@merijn-l1 on 2004/01/21 21:10:10

[perl #25160] ':flock' not recognized unless it's first
Exporter::Heavy now will treat :, /, and ! special in
all arguments, not only if the _first_ arg starts with it
Date: Wed, 21 Jan 2004 08:32:47 -0500
Message-ID: <200401211332...@plover.com>

Affected files ...

... //depot/perl/lib/Exporter/Heavy.pm#22 edit

Differences ...

==== //depot/perl/lib/Exporter/Heavy.pm#22 (text) ====

@@ -69,7 +69,7 @@
$cache_is_current = 1;
}

- if ($imports[0] =~ m#^[/!:]#){

+ if (grep m{^[/!:]}, @imports) {


my $tagsref = \%{"${pkg}::EXPORT_TAGS"};
my $tagdata;
my %imports;

> }
>

> Also I don't think your version will recognize ":foo" in the first
> @import element. You might want your RE to be m{^[/!:]}m instead.
>
> Regards,
> Gisle

--

Gisle Aas

unread,
Jan 21, 2004, 5:59:23 PM1/21/04
to H.Merijn Brand, Perl 5 Porters
"H.Merijn Brand" <h.m....@hccnet.nl> writes:

> Test cases welcome still
>
> Change 22192 by merijn@merijn-l1 on 2004/01/21 21:10:10
>
> [perl #25160] ':flock' not recognized unless it's first
> Exporter::Heavy now will treat :, /, and ! special in
> all arguments, not only if the _first_ arg starts with it
> Date: Wed, 21 Jan 2004 08:32:47 -0500
> Message-ID: <200401211332...@plover.com>
>
> Affected files ...
>
> ... //depot/perl/lib/Exporter/Heavy.pm#22 edit

You should also patch up the Exporter documentation that explained the
old behaviour of "If the first entry in an import list begins with !,
: or /".

--Gisle

H.Merijn Brand

unread,
Jan 21, 2004, 7:36:15 PM1/21/04
to Gisle Aas, Perl 5 Porters
On Wed 21 Jan 2004 23:59, Gisle Aas <gi...@ActiveState.com> wrote:
> "H.Merijn Brand" <h.m....@hccnet.nl> writes:
>
> > Test cases welcome still
> >
> > Change 22192 by merijn@merijn-l1 on 2004/01/21 21:10:10
> >
> > [perl #25160] ':flock' not recognized unless it's first
> > Exporter::Heavy now will treat :, /, and ! special in
> > all arguments, not only if the _first_ arg starts with it
> > Date: Wed, 21 Jan 2004 08:32:47 -0500
> > Message-ID: <200401211332...@plover.com>
> >
> > Affected files ...
> >
> > ... //depot/perl/lib/Exporter/Heavy.pm#22 edit
>
> You should also patch up the Exporter documentation that explained the
> old behaviour of "If the first entry in an import list begins with !,
> : or /".

Somewhat like below? Does the *change* need to be documented?
Do we need a version increase?
We *do* need tests (I am not good in tests: hint hint)

--- lib/Exporter.pm.org 2004-01-22 01:32:23.000000000 +0100
+++ lib/Exporter.pm 2004-01-22 01:34:17.000000000 +0100
@@ -212,9 +212,9 @@ need to know to use Exporter.

=head2 Specialised Import Lists

-If the first entry in an import list begins with !, : or / then the
-list is treated as a series of specifications which either add to or
-delete from the list of names to import. They are processed left to
+If any of the entries in an import list begins with !, : or / then
+the list is treated as a series of specifications which either add to
+or delete from the list of names to import. They are processed left to
right. Specifications are in the form:

[!]name This name only

Nicholas Clark

unread,
Jan 22, 2004, 6:26:57 AM1/22/04
to H.Merijn Brand, Gisle Aas, Perl 5 Porters
On Thu, Jan 22, 2004 at 01:36:15AM +0100, H.Merijn Brand wrote:
> On Wed 21 Jan 2004 23:59, Gisle Aas <gi...@ActiveState.com> wrote:
> > "H.Merijn Brand" <h.m....@hccnet.nl> writes:
> >
> > > Test cases welcome still
> > >
> > > Change 22192 by merijn@merijn-l1 on 2004/01/21 21:10:10
> > >
> > > [perl #25160] ':flock' not recognized unless it's first
> > > Exporter::Heavy now will treat :, /, and ! special in
> > > all arguments, not only if the _first_ arg starts with it
> > > Date: Wed, 21 Jan 2004 08:32:47 -0500
> > > Message-ID: <200401211332...@plover.com>
> > >
> > > Affected files ...
> > >
> > > ... //depot/perl/lib/Exporter/Heavy.pm#22 edit
> >
> > You should also patch up the Exporter documentation that explained the
> > old behaviour of "If the first entry in an import list begins with !,
> > : or /".
>
> Somewhat like below? Does the *change* need to be documented?

I'd be happier if we actually documented that a change was made.
I'm expecting that module authors will be creating or testing modules
on 5.8.x with this, upload the module to CPAN, and then be surprised
about bug reports from 5.8.3 and earlier. So I'd like to mention it in
perl584delta, and link to Exporter's documentation.

I fully expect many module authors not to read the documentation until after
the bug report, but I'm much happier to have the blame transfer already in
place.

> Do we need a version increase?

Definitely by 5.8.4, yes. I think that this change is significant
enough to justify it, given that we're unlikely to patch Exporter again
in the next couple of months.

> We *do* need tests (I am not good in tests: hint hint)

Calling all happy passive readers of perl5-porters - submit a patch, get
your name into the AUTHORS file: fame, immortality and more spam.

Nicholas Clark

0 new messages