Return-Path: Delivered-To: apmail-perl-dev-archive@www.apache.org Received: (qmail 17587 invoked from network); 6 Nov 2008 20:40:27 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 6 Nov 2008 20:40:27 -0000 Received: (qmail 39402 invoked by uid 500); 6 Nov 2008 20:40:33 -0000 Delivered-To: apmail-perl-dev-archive@perl.apache.org Received: (qmail 39385 invoked by uid 500); 6 Nov 2008 20:40:33 -0000 Mailing-List: contact dev-help@perl.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list dev@perl.apache.org Received: (qmail 39374 invoked by uid 99); 6 Nov 2008 20:40:33 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Nov 2008 12:40:33 -0800 X-ASF-Spam-Status: No, hits=1.2 required=10.0 tests=SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [66.249.92.171] (HELO ug-out-1314.google.com) (66.249.92.171) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Nov 2008 20:39:16 +0000 Received: by ug-out-1314.google.com with SMTP id j40so1124121ugd.26 for ; Thu, 06 Nov 2008 12:39:56 -0800 (PST) Received: by 10.103.40.5 with SMTP id s5mr1330378muj.4.1226003996347; Thu, 06 Nov 2008 12:39:56 -0800 (PST) Received: by 10.103.167.12 with HTTP; Thu, 6 Nov 2008 12:39:56 -0800 (PST) Message-ID: Date: Thu, 6 Nov 2008 15:39:56 -0500 From: "Casey West" Sender: casey@onewestway.com To: dev@perl.apache.org Subject: [PATCH] prototypes/constant redefinition warnings from ModPerl::Util MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_30116_22096032.1226003996319" X-Google-Sender-Auth: 07be76a67033c648 X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_30116_22096032.1226003996319 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi, Apache2::Reload relies on ModPerl::Util::unload_package_pp to disassemble a stash entry before importing the code again. I like how it does this with two exceptions. First, prototypes. unload_package_pp() takes care to retain the prototype when redefining a code stash entry. That's a good thing because it (typically) avoids a warning. Then it removes the subroutine from the stash using undef(). That's not so hot because undef takes the liberty to explicitly undefine the prototype of that subroutine. In the case of Apache2::Reload, what happens next is we remake a prototyped subroutine - lets use try() from Error.pm for illustration - and get warnings about mismatched prototypes. perl believes the prototype for this subroutine is not defined, Error tries to define it as (&;$), and perl warns about "none vs. (&;$)" prototype mismatch. This can be avoided by explicitly deleting the CODE slot in the stash entry, like this: "delete ${$fullname}{CODE};" This will remove the body of the coderef but leave the prototype in tact. Second, constant redefinitions. In this case the assignment of an empty subroutine (with proper prototype) throws a warning, only in the case of constant subroutines. Take something created by "use constant" as an example, and combine that with Apache2::Reload. unload_package_pp() makes every attempt to turn off warnings but can't, for whatever reason, make it work for this one. The reason, I found through copious trial and error and a pairing session with Adam Foxson, is to turn off the warning directly in the eval, like this: *{$fullname} = eval "no warmings 'redefine'; sub ($p) {}"; I am not sure why the redefinition warning is thrown from this lexical scope. Nevertheless, a solution is found. Attached is a patch which accounts for these two problems. Please consider it. Cheers, -- Casey West ------=_Part_30116_22096032.1226003996319 Content-Type: text/x-patch; name=mp-ap2-reload-warnings-stfu.patch Content-Transfer-Encoding: base64 X-Attachment-Id: f_fn7v2rul0 Content-Disposition: attachment; filename=mp-ap2-reload-warnings-stfu.patch SW5kZXg6IHhzL01vZFBlcmwvVXRpbC9VdGlsX3BtCj09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLS0tIHhzL01vZFBlcmwv VXRpbC9VdGlsX3BtCShyZXZpc2lvbiA3MTE5NTApCisrKyB4cy9Nb2RQZXJsL1V0aWwvVXRpbF9w bQkod29ya2luZyBjb3B5KQpAQCAtMzksMTIgKzM5LDEyIEBACiAgICAgICAgICAgICBubyB3YXJu aW5nczsKICAgICAgICAgICAgIGxvY2FsICReVyA9IDA7CiAgICAgICAgICAgICBpZiAoZGVmaW5l ZChteSAkcCA9IHByb3RvdHlwZSAkZnVsbG5hbWUpKSB7Ci0gICAgICAgICAgICAgICAgKnskZnVs bG5hbWV9ID0gZXZhbCAic3ViICgkcCkge30iOworICAgICAgICAgICAgICAgICp7JGZ1bGxuYW1l fSA9IGV2YWwgIm5vIHdhcm5pbmdzICdyZWRlZmluZSc7IHN1YiAoJHApIHt9IjsKICAgICAgICAg ICAgIH0KICAgICAgICAgICAgIGVsc2UgewogICAgICAgICAgICAgICAgICp7JGZ1bGxuYW1lfSA9 IHN1YiB7fTsKICAgICAgICAgICAgIH0KLSAgICAgICAgICAgIHVuZGVmICYkZnVsbG5hbWU7Cisg ICAgICAgICAgICBkZWxldGUgJHskZnVsbG5hbWV9e0NPREV9OwogICAgICAgICB9CiAgICAgICAg IGlmICgqeyRmdWxsbmFtZX17SU99KSB7CiAgICAgICAgICAgICBsb2NhbCAkQDsK ------=_Part_30116_22096032.1226003996319 Content-Type: text/plain; charset=us-ascii --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org For additional commands, e-mail: dev-help@perl.apache.org ------=_Part_30116_22096032.1226003996319--