Re: Installing A-A-P

Bram Moolenaar <[email protected]>
Newsgroups gmane.comp.tools.aap.devel
Message-ID <[email protected]>
Wichert Akkerman wrote:

> Previously Bram Moolenaar wrote:
> > Is this possible?  Currently the pre module is imported to test for the
> > bug.  Once the pre module has been imported, how to replace the wrong
> > code?  Overwrite the reference to the function definition somehow?
> 
> A function is just a variable of type function, so you can assign to it
> at will. For example:
> 
> >>> import pre
> /usr/lib/python2.3/pre.py:94: DeprecationWarning: Please use the 're' module, not the 'pre' module DeprecationWarning)
> >>> def error():
> ...     print "My own error"
> ...
> >>> pre.error=error
> >>> pre.error()
> My own error

Well, it's a bit more complicated than that, because the function that
contains the bug is part of a class.  It's still possible to replace the
function, taking care to modify it for the different context.

It is a hack, but it appears to work.  I'll put it in CVS today and
await any complaints.

Python experts, please look into what I made and comment.  Keep a bucket
ready! :-)

-- 
Bad fashion can discourage normal people from interacting with the engineer
and talking about the cute things their children do.
				(Scott Adams - The Dilbert principle)

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///          Creator of Vim - Vi IMproved -- http://www.Vim.org          \\\
\\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
 \\\  Help AIDS victims, buy here: http://ICCF-Holland.org/click1.html  ///


-------------------------------------------------------
This SF.Net email sponsored by: ApacheCon 2003,
16-19 November in Las Vegas. Learn firsthand the latest
developments in Apache, PHP, Perl, XML, Java, MySQL,
WebDAV, and more! http://www.apachecon.com/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.