Open p5pRT opened 12 years ago
It looks like warnings will fatally error with flags for future catagories:
Unknown warnings category 'non_unicode'
This makes it rather hard to use any of the newer categories without figuring out exactly which version of Perl the category came from.
On Mon May 14 05:30:47 2012\, Perl@ResonatorSoft.org wrote:
It looks like warnings will fatally error with flags for future catagories:
Unknown warnings category 'non_unicode'
This makes it rather hard to use any of the newer categories without figuring out exactly which version of Perl the category came from.
But what do we do if someone mistypes a warnings category?
Iām not trying to suggest that your concern is not valid. It *is* a valid concern\, but it is not clear how to proceed.
We also have a problem with custom-registered warnings categories. (See \https://rt-archive.perl.org/perl5/Ticket/Display.html?id=108778.)
It should be possible for someone to say āuse warnings "foo"ā\, before the foo module registers itself as a warnings category.
Now\, if such a foo module never registers itself\, or was actually called fooo and was mistyped\, should we get a warning\, or not? (The warning could be delayed until the main programās run time\, which is how āused onceā warnings work.)
If we do have a warning\, then disabling it would be weird:
no warnings "warnings"; # warnings about misuse of warnings.pm use warnings "foo";
Or:
BEGIN { local $SIG{__WARN__} = sub {}; require warnings; import warnings "foo"; }
So\, it looks to me as though\, while itās nice to have a typo check\, it conflicts with valid usage in actual practice.
--
Father Chrysostomos
The RT System itself - Status changed from 'new' to 'open'
"Father Chrysostomos via RT" \perlbug\-followup@​perl\.org wrote on Thu\, 17 May 2012 13:09:58 PDT:
But what do we do if someone mistypes a warnings category?
Iām not trying to suggest that your concern is not valid. It *is* a valid concern\, but it is not clear how to proceed.
Is this a reason to have
use if $] >= 5.014\, warnings => "non_unicode";
Do I dare floating-point there\, or should that be doing some $^V dance? I notice I have some code that reads:
if $^V >= v5.11.3\, qw[ feature unicode_strings ];
Which I hope will work. I'm a bit fuzzy on v-strings and versioning\, and which operators one can use vs cannot use.
--tom
On Thu May 17 13:34:54 2012\, tom christiansen wrote:
"Father Chrysostomos via RT" \perlbug\-followup@​perl\.org wrote on Thu\, 17 May 2012 13:09:58 PDT:
But what do we do if someone mistypes a warnings category?
Iām not trying to suggest that your concern is not valid. It *is* a valid concern\, but it is not clear how to proceed.
Is this a reason to have
use if $\] >= 5\.014\, warnings => "non\_unicode";
Thatās a good used of if.pm that I hadnāt thought of.
Do I dare floating-point there\, or should that be doing some $^V dance? I notice I have some code that reads:
if $^V >= v5\.11\.3\, qw\[ feature unicode\_strings \];
Which I hope will work. I'm a bit fuzzy on v-strings and versioning\, and which operators one can use vs cannot use.
Since 5.10\, $^V can be used with either ge or >= with either vstring or floating point as the other operand.
In 5.6 and 5.8\, $^V is a dualvar\, so either $^V >= 5.014 or $^V ge v5.14 will work\, but not $^V >= v5.14 or $^V ge 5.014 (which only work in 5.10+).
--
Father Chrysostomos
Tom Christiansen wrote:
use if $] >= 5.014\, warnings => "non_unicode";
Do I dare floating-point there\, or should that be doing some $^V dance?
The floating point will work fine. On sufficiently recent perls\, $] is effectively built as a string\, and then converted for numeric use. Your floating-point literal gets converted in an equivalent way\, so that all works.
On older perls\, however\, $] had a numeric value that was built up using floating-point arithmetic\, such as 5+0.006+0.000002. This would not necessarily match the conversion of the complete value from string form [perl #72210]. You can work around that by explicitly stringifying $] (which produces a correct string) and having *that* numify (to a correctly-converted floating point value) for comparison. I cultivate the habit of always stringifying $] to work around this\, regardless of the threshold where the bug was fixed. So I'd write
use if "$]" >= 5.014\, warnings => "non_unicode";
-zefram
On Fri\, May 18\, 2012 at 9:05 AM\, Zefram via RT \perlbug\-followup@​perl\.org wrote:
Ā Ā use if "$]" >= 5.014\, warnings => "non_unicode";
$] is old; don't use it. $^V has been around since Perl 5.6.0\, which is older than dirt now.
Steering this report back on topic\, the warnings items could have some sort of version tied to it:
use warnings "v5.14-non_unicode"
Then "earlier" versions of warnings could parse that and ignore it if it's a newer version than $^V. Of course\, the cat's alright out of the bag\, so a fix to warnings.pm won't work until 5.16\, not without some heavy backporting.
My current workaround is checking %warnings::Offsets\, which is kinda hacky. Of course\, for something like a single declaration like "use warnings non_unicode"\, a $^V check will work. However\, it's the kind of bug you don't really notice until somebody with an older version of Perl chimes in with a bug report.
-- Brendan Byrd \Perl@​ResonatorSoft\.org Brendan Byrd \BBYRD@​CPAN\.org
warnings croaks if it is given an unrecognized category. This makes it difficult for code to easily support multiple versions of perl where one possses a warning that the author would like to disable\, and the other does not.
For instance\, Curses::UI previously (now fixed\, but the unfixed version is still shipping on Fedora) had prototypes of I\<@;> for many subroutines. Perl 5.12 introduced the illegalproto warning against this.
no warnings 'illegalproto';
can disable this warning\, in 5.12+\, but causes earlier versions to die. Thus\, if one does not want to fight the system package manager (or those who are limited to its use rather than CPAN) to keep a recent module version installed\, an awkward workaround is required like:
BEGIN{ if( $^V lt v5.12.0 ){ eval "use Curses::UI" } else{ eval "no warnings 'illegalproto'; use Curses::UI" } }
Unfortunately a true fix for this issue may be difficult to fix in a useful way since the design decision was made sometime ago and the croaking version is widespread/core to older perls\, but dual-lifeing warnings on CPAN might help
Migrated from rt.perl.org#112920 (status was 'open')
Searchable as RT112920$