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
an extra check for __FILE__ in strict.pm contradicts to documentation #15171
Comments
From Vadim.Konovalov@emc.comThis is a bug report for perl from vadim.konovalov@emc.com, The lib/strict.pm module contains this check: unless ( __FILE__ =~ /(^|[\/\\])\Q${\__PACKAGE__}\E\.pmc?$/ ) { The above chunk of code assumes that it is called from a file on However - this check violates documented behaviour. =quote eval "require $class"; Now that you understand how "require" looks for files with a You can also insert hooks into the import facility by putting Therefore I must be able to place a code ref into @INC array which In other words - the filename check in "strict.pm" contradicts to This deviation from documented behaviour breaks my hand-crafted Similar problem exists in warnings.pm Flags: Site configuration information for perl 5.16.0: Configured by vkonoval at Mon May 21 13:33:55 2012. Summary of my perl5 (revision 5 version 16 subversion 0) configuration: Locally applied patches: @INC for perl 5.16.0: Environment for perl 5.16.0: Complete configuration data for perl 5.16.0: Author='' |
From @maukeAm 11.02.2016 um 08:40 schrieb Konovalov@rt.perl.org:
No. What do you mean by "therefore"? The documentation literally does
It doesn't contradict the documentation (and if it did, we'd change the -- |
The RT System itself - Status changed from 'new' to 'open' |
From Vadim.Konovalov@emc.comLe Jeu 11 Fév 2016 07:12:24, plokinom@gmail.com a écrit :
yes it does states that I can use code ref with @INC array. actually - when I wrote my old code - I consulted several places of I also consulted "perldoc perlsub", it has advises on how to override =quote I actually overrid "do", "require" to provide all requieted modules, I was following Perl documentation. Honestly.
the bug is in Perl - because it does not conform to documented behaviour.
whether or not I can fix my own "crafted mechanism" by inserting #line here and there - there's another question. I state that when I wrote mentioned code - I closely followed perl documentatiom, I am good perl citizen who did "perldoc" often. New behaviour makes my old mechanism catched by trap - in spite of some other users who are now more happy by being warned more often. |
From Vadim.Konovalov@emc.comattached patches remove an assumption that strict.pm (and warnings.pm) must reside on a file on a filesystem, Still, "use Strict" possible user error detected, plus regular expression made simplier and thus easier to comprehend. Yet, moved the check few lines to the bottom. thanks in advance for considering these. |
From Vadim.Konovalov@emc.comInline Patch--- strict.pm- 2016-01-08 18:22:20.246454624 +0000
+++ strict.pm 2016-02-12 03:25:03.983559206 +0000
@@ -2,13 +2,6 @@
$strict::VERSION = "1.09";
-# Verify that we're called correctly so that strictures will work.
-unless ( __FILE__ =~ /(^|[\/\\])\Q${\__PACKAGE__}\E\.pmc?$/ ) {
- # Can't use Carp, since Carp uses us!
- my (undef, $f, $l) = caller;
- die("Incorrect use of pragma '${\__PACKAGE__}' at $f line $l.\n");
-}
-
my ( %bitmask, %explicit_bitmask );
BEGIN {
@@ -35,6 +28,14 @@
my $inline_all_explicit_bits = $bits;
*all_explicit_bits = sub () { $inline_all_explicit_bits };
+
+ # Verify that we're called correctly so that strictures will work.
+ if ( __FILE__ =~ /(\w+)\.pmc?$/ and $1 ne __PACKAGE__ ) {
+ # Can't use Carp, since Carp uses us!
+ my (undef, $f, $l) = caller;
+ die("Incorrect use of pragma '${\__PACKAGE__}' at $f line $l.\n");
+ }
+
}
sub bits { |
From Vadim.Konovalov@emc.comInline Patch--- warnings.pl- 2015-10-30 20:21:20.000000000 +0000
+++ warnings.pl 2016-02-12 03:38:13.493006659 +0000
@@ -16,7 +16,7 @@
#
# This script is normally invoked from regen.pl.
-$VERSION = '1.34';
+$VERSION = '1.35';
BEGIN {
require 'regen/regen_lib.pl';
@@ -494,7 +494,7 @@
# Verify that we're called correctly so that warnings will work.
# see also strict.pm.
-unless ( __FILE__ =~ /(^|[\/\\])\Q${\__PACKAGE__}\E\.pmc?$/ ) {
+if ( __FILE__ =~ /(\w+).pmc?$/ and $1 ne __PACKAGE__ ) {
my (undef, $f, $l) = caller;
die("Incorrect use of pragma '${\__PACKAGE__}' at $f line $l.\n");
} |
From Vadim.Konovalov@emc.com...better patch |
From Vadim.Konovalov@emc.comInline Patch--- strict.pm- 2016-01-08 18:22:20.246454624 +0000
+++ strict.pm 2016-02-12 03:31:52.792023871 +0000
@@ -1,13 +1,6 @@
package strict;
-$strict::VERSION = "1.09";
-
-# Verify that we're called correctly so that strictures will work.
-unless ( __FILE__ =~ /(^|[\/\\])\Q${\__PACKAGE__}\E\.pmc?$/ ) {
- # Can't use Carp, since Carp uses us!
- my (undef, $f, $l) = caller;
- die("Incorrect use of pragma '${\__PACKAGE__}' at $f line $l.\n");
-}
+$strict::VERSION = "1.10";
my ( %bitmask, %explicit_bitmask );
@@ -35,6 +28,14 @@
my $inline_all_explicit_bits = $bits;
*all_explicit_bits = sub () { $inline_all_explicit_bits };
+
+ # Verify that we're called correctly so that strictures will work.
+ if ( __FILE__ =~ /(\w+)\.pmc?$/ and $1 ne __PACKAGE__ ) {
+ # Can't use Carp, since Carp uses us!
+ my (undef, $f, $l) = caller;
+ die("Incorrect use of pragma '${\__PACKAGE__}' at $f line $l.\n");
+ }
+
}
sub bits { |
Migrated from rt.perl.org#127512 (status was 'open')
Searchable as RT127512$
The text was updated successfully, but these errors were encountered: