Replace "x.has_key(y)" with "y in x"

[email protected] Fri, 09 Oct 2009 11:51:51 -0000
Newsgroups gmane.comp.python.twisted.bugs
Message-ID <[email protected]>
New submission from Screwtape <[email protected]>:

Ticket #2484 is all about preparing Twisted to be ported to Python 3 with the 2to3 tool; a big part of this is changing code that uses features removed in Python 3 to use newer syntax. One of the most frequent warnings issued when you run the Twisted test suite in "warn about Python 3.x incompatibilities mode" is "dict.has_key() not supported in 3.x; use the in operator", and that's a pretty easy thing to clean up.

The attached patch applies to today's SVN trunk, causes no test failures on my machine in normal Python 2.6, and removes all but 47 of the "has_key" warnings when running Twisted's test suite. These last 47 warnings are raised by `/usr/lib/python2.6/xml/dom/minidom.py`, so I don't think it's Twisted's responsibility to fix. :)


----------
Type     : enhancement
Component: core
Keywords : py3k
Priority : normal
Nosy     : 
----------
http://twistedmatrix.com/trac/ticket/4053