From: Vincent Pit Date: Tue, 18 Aug 2015 15:01:22 +0000 (-0300) Subject: This is 0.28 X-Git-Tag: v0.28 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=c1a323d9283261193f57c78f83e0ebab8b770164;p=perl%2Fmodules%2FScope-Upper.git This is 0.28 --- diff --git a/Changes b/Changes index 115c7e2..d05b228 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,20 @@ Revision history for Scope-Upper +0.28 2015-08-18 15:00 UTC + + Chg : SUB() and EVAL() will now warn if they cannot find an + appropriate context in the current stack. They will still + return undef in this case, which is interpreted as the current + context when combined with other words. + + Fix : [RT #104751] : Scope::Upper does not handle exotic stack types + Trying to target a scope above the current perl scope will now + result in a warning. In that case, the topmost context in the + current stack will still be returned. + Thanks Rafaël Garcia-Suarez for the report. + + Fix : Test failures of threads tests on systems with harsh resource + constraints causing the threads to exit() during run. + + Opt : Some internal structures were shrunk, resulting in memory + savings and small speedups. + 0.27 2015-03-27 22:10 UTC + Chg : The new environment variable to enable thread tests on older perls is PERL_FORCE_TEST_THREADS. Note that this variable diff --git a/META.json b/META.json index 8e10723..7c6767d 100644 --- a/META.json +++ b/META.json @@ -4,7 +4,7 @@ "Vincent Pit " ], "dynamic_config" : 1, - "generated_by" : "ExtUtils::MakeMaker version 7.04, CPAN::Meta::Converter version 2.150001", + "generated_by" : "ExtUtils::MakeMaker version 7.0401, CPAN::Meta::Converter version 2.150005", "license" : [ "perl_5" ], @@ -59,5 +59,6 @@ "url" : "http://git.profvince.com/?p=perl%2Fmodules%2FScope-Upper.git" } }, - "version" : "0.27" + "version" : "0.28", + "x_serialization_backend" : "JSON::PP version 2.27300" } diff --git a/META.yml b/META.yml index bdb3edf..c8cb99c 100644 --- a/META.yml +++ b/META.yml @@ -14,7 +14,7 @@ configure_requires: Config: '0' ExtUtils::MakeMaker: '0' dynamic_config: 1 -generated_by: 'ExtUtils::MakeMaker version 7.04, CPAN::Meta::Converter version 2.150001' +generated_by: 'ExtUtils::MakeMaker version 7.0401, CPAN::Meta::Converter version 2.150005' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html @@ -34,4 +34,5 @@ resources: homepage: http://search.cpan.org/dist/Scope-Upper/ license: http://dev.perl.org/licenses/ repository: http://git.profvince.com/?p=perl%2Fmodules%2FScope-Upper.git -version: '0.27' +version: '0.28' +x_serialization_backend: 'CPAN::Meta::YAML version 0.016' diff --git a/README b/README index a160e7f..5221b5a 100644 --- a/README +++ b/README @@ -2,7 +2,7 @@ NAME Scope::Upper - Act on upper scopes. VERSION - Version 0.27 + Version 0.28 SYNOPSIS "reap", "localize", "localize_elem", "localize_delete" and "WORDS" : @@ -570,21 +570,29 @@ WORDS my $upper_context = UP; my $upper_context = UP $from; - The context of the scope just above $from. + The context of the scope just above $from. If $from points to the + top-level scope in the current stack, then a warning is emitted and + $from is returned (see "DIAGNOSTICS" for details). "SUB" my $sub_context = SUB; my $sub_context = SUB $from; - The context of the closest subroutine above $from. Note that $from is - returned if it is already a subroutine context ; hence "SUB SUB == SUB". + The context of the closest subroutine above $from. If $from already + designates a subroutine context, then it is returned as-is ; hence "SUB + SUB == SUB". If no subroutine context is present in the call stack, then + a warning is emitted and the current context is returned (see + "DIAGNOSTICS" for details). "EVAL" my $eval_context = EVAL; my $eval_context = EVAL $from; - The context of the closest eval above $from. Note that $from is returned - if it is already an eval context ; hence "EVAL EVAL == EVAL". + The context of the closest eval above $from. If $from already designates + an eval context, then it is returned as-is ; hence "EVAL EVAL == EVAL". + If no eval context is present in the call stack, then a warning is + emitted and the current context is returned (see "DIAGNOSTICS" for + details). Getting a context from a level Here, $level should denote a number of scopes above the current one. @@ -595,7 +603,10 @@ WORDS my $context = SCOPE; my $context = SCOPE $level; - The $level-th upper context, regardless of its type. + The $level-th upper context, regardless of its type. If $level points + above the top-level scope in the current stack, then a warning is + emitted and the top-level context is returned (see "DIAGNOSTICS" for + details). "CALLER" my $context = CALLER; @@ -604,7 +615,9 @@ WORDS The context of the $level-th upper subroutine/eval/format. It kind of corresponds to the context represented by "caller $level", but while e.g. "caller 0" refers to the caller context, "CALLER 0" will refer to - the top scope in the current context. + the top scope in the current context. If $level points above the + top-level scope in the current stack, then a warning is emitted and the + top-level context is returned (see "DIAGNOSTICS" for details). Examples Where "reap" fires depending on the $cxt : @@ -669,6 +682,20 @@ WORDS # (*) Note that uplevel() will croak if you pass that scope frame, # because it cannot target eval scopes. +DIAGNOSTICS + "Cannot target a scope outside of the current stack" + This warning is emitted when "UP", "SCOPE" or "CALLER" end up pointing + to a context that is above the top-level context of the current stack. + It indicates that you tried to go higher than the main scope, or to + point across a "DESTROY" method, a signal handler, an overloaded or tied + method call, a "require" statement or a "sort" callback. In this case, + the resulting context is the highest reachable one. + + "No targetable %s scope in the current stack" + This warning is emitted when you ask for an "EVAL" or "SUB" context and + no such scope can be found in the call stack. The resulting context is + the current one. + EXPORT The functions "reap", "localize", "localize_elem", "localize_delete", "unwind", "yield", "leave", "want_at", "context_info" and "uplevel" are @@ -683,6 +710,11 @@ EXPORT ':words' and ':all'. CAVEATS + It is not possible to act upon a scope that belongs to another perl + 'stack', i.e. to target a scope across a "DESTROY" method, a signal + handler, an overloaded or tied method call, a "require" statement or a + "sort" callback. + Be careful that local variables are restored in the reverse order in which they were localized. Consider those examples: @@ -781,9 +813,6 @@ SUPPORT perldoc Scope::Upper - Tests code coverage report is available at - . - ACKNOWLEDGEMENTS Inspired by Ricardo Signes. diff --git a/lib/Scope/Upper.pm b/lib/Scope/Upper.pm index ab3bd67..87f4344 100644 --- a/lib/Scope/Upper.pm +++ b/lib/Scope/Upper.pm @@ -11,13 +11,13 @@ Scope::Upper - Act on upper scopes. =head1 VERSION -Version 0.27 +Version 0.28 =cut our $VERSION; BEGIN { - $VERSION = '0.27'; + $VERSION = '0.28'; } =head1 SYNOPSIS