[PATCH] hgweb_mod: fix key error on file display

Christian Ebert blacktrash at gmx.net
Sun Jan 20 04:46:20 CST 2008


* Bryan O'Sullivan on Saturday, January 19, 2008 at 21:24:58 -0800
> Christian Ebert wrote:
> 
>> -                if cmd == 'file' and 'raw' in req.form['style']:
>> +                if (cmd == 'file' and
>> +                    req.form.has_key('style') and 'raw' in req.form['style']):
> 
> Prefer a smaller modification to the original:
> 
>  'raw' in req.form.get('style', [])

Of course much better. That's what I meant ;)

> Also, the has_key method is a holdover from Python 1.x.  "a in b" is
> more idiomatic.

I seem to remember to have read somewher that has_key was still
the preferred method, even in some official py docs, but I must
have been imagining things, can't find the reference.

c
-- 
_B A U S T E L L E N_ lesen! --->> <http://www.blacktrash.org/baustellen.html>


More information about the Mercurial-devel mailing list