[PATCH] Provide better context for custom Python encode/decode filters

Jesse Glick jesse.glick at sun.com
Sat Dec 22 04:18:52 UTC 2007


Bryan O'Sullivan wrote:
>> Provide better context for custom Python encode/decode filters.
> 
> This breaks the API of any other filters, unfortunately.

It should be compatible for old filters, if that is what you mean:

try:
     return fn(s, cmd, **kwargs)
except TypeError:
     return fn(s, cmd)

You can see that in the patch, most of the filters were not in fact 
changed, just the *decode functions that needed the new parameters.

One annoying side effect of the above implementation is that if the body 
of a new-style filter throws TypeError for some unrelated reason, it 
will be reinvoked with no extra args, which masks the real problem and 
produces a confusing error. I will see if it can be reworked to use 
inspect.getargspec instead.

-- 
jesse.glick at sun.com netbeans.org ant.apache.org hudson.dev.java.net
selenic.com/mercurial http://google.com/search?q=e%5E%28pi*i%29%2B1




More information about the Mercurial-devel mailing list