← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~cjwatson/launchpad/remove-has-key into lp:launchpad

 

Colin Watson has proposed merging lp:~cjwatson/launchpad/remove-has-key into lp:launchpad.

Commit message:
Use "key in dict" rather than dict.has_key(key).

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/remove-has-key/+merge/285335

Use "key in dict" rather than dict.has_key(key).

This is part of preparation for an eventual port to Python 3, but really I'm just doing this as a harmless change to get qastaging going again.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/remove-has-key into lp:launchpad.
=== modified file 'lib/lp/bugs/tests/bugs-emailinterface.txt'
--- lib/lp/bugs/tests/bugs-emailinterface.txt	2016-01-26 15:47:37 +0000
+++ lib/lp/bugs/tests/bugs-emailinterface.txt	2016-02-08 12:47:55 +0000
@@ -75,7 +75,7 @@
     >>> def construct_email(raw_mail):
     ...     msg = email.message_from_string(
     ...         raw_mail, _class=MockSignedMessage)
-    ...     if not msg.has_key('Message-Id'):
+    ...     if 'Message-Id' not in msg:
     ...         msg['Message-Id'] = factory.makeUniqueRFC822MsgId()
     ...     return msg
 

=== modified file 'lib/lp/services/webapp/doc/webapp-publication.txt'
--- lib/lp/services/webapp/doc/webapp-publication.txt	2016-01-26 15:14:01 +0000
+++ lib/lp/services/webapp/doc/webapp-publication.txt	2016-02-08 12:47:55 +0000
@@ -595,7 +595,7 @@
 
 Originally, this variable isn't set.
 
-    >>> request._orig_env.has_key('launchpad.pageid')
+    >>> 'launchpad.pageid' in request._orig_env
     False
 
 It is set during the callObject() hook. The pageid is made of the
@@ -637,7 +637,7 @@
 hook and stop the count in afterTraversal().  The tick count is then
 available as launchpad.traversalticks in the WSGI environment.
 
-    >>> request._orig_env.has_key('launchpad.traversalticks')
+    >>> 'launchpad.traversalticks' in request._orig_env
     False
     >>> publication.beforeTraversal(request)
     >>> tickcount.difference(
@@ -652,7 +652,7 @@
 hook and stop the count in afterCall().  The tick count is then
 available as launchpad.publicationticks in the WSGI environment.
 
-    >>> request._orig_env.has_key('launchpad.publicationticks')
+    >>> 'launchpad.publicationticks' in request._orig_env
     False
     >>> publication.callObject(request, TestView(TestContext(), request))
     u'Result'
@@ -687,9 +687,9 @@
     >>> set_request_started()
     >>> publication.handleException(
     ...     None, request, exc_info, retry_allowed=False)
-    >>> request._orig_env.has_key('launchpad.traversalticks')
+    >>> 'launchpad.traversalticks' in request._orig_env
     False
-    >>> request._orig_env.has_key('launchpad.publicationticks')
+    >>> 'launchpad.publicationticks' in request._orig_env
     False
     >>> clear_request_started()
 
@@ -701,7 +701,7 @@
     ...     None, request, exc_info, retry_allowed=False)
     >>> request._orig_env['launchpad.traversalticks'] < 200
     True
-    >>> request._orig_env.has_key('launchpad.publicationticks')
+    >>> 'launchpad.publicationticks' in request._orig_env
     False
     >>> clear_request_started()
 
@@ -744,9 +744,9 @@
     ...
     Retry: foo
 
-    >>> request._orig_env.has_key('launchpad.publicationticks')
+    >>> 'launchpad.publicationticks' in request._orig_env
     False
-    >>> request._orig_env.has_key('launchpad.traversalticks')
+    >>> 'launchpad.traversalticks' in request._orig_env
     False
 
     >>> request, publication = get_request_and_publication()
@@ -766,9 +766,9 @@
     ...
     Retry: foo DisconnectionError
 
-    >>> request._orig_env.has_key('launchpad.publicationticks')
+    >>> 'launchpad.publicationticks' in request._orig_env
     False
-    >>> request._orig_env.has_key('launchpad.traversalticks')
+    >>> 'launchpad.traversalticks' in request._orig_env
     False
 
 Of course, any request can only be retried a certain number of times and

=== modified file 'lib/lp/services/webapp/notifications.py'
--- lib/lp/services/webapp/notifications.py	2015-10-14 15:22:01 +0000
+++ lib/lp/services/webapp/notifications.py	2016-02-08 12:47:55 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2016 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Browser notification messages
@@ -155,13 +155,13 @@
 
     >>> session = ISession(request)[SESSION_KEY]
     >>> del ISession(request)[SESSION_KEY]['notifications']
-    >>> session.has_key('notifications')
+    >>> 'notifications' in session
     False
     >>> len(response.notifications)
     0
     >>> response.redirect("http://example.com";)
     302: http://example.com
-    >>> session.has_key('notifications')
+    >>> 'notifications' in session
     False
     """
 

=== modified file 'lib/lp/services/webapp/publisher.py'
--- lib/lp/services/webapp/publisher.py	2015-07-08 16:05:11 +0000
+++ lib/lp/services/webapp/publisher.py	2016-02-08 12:47:55 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009-2013 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2016 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Publisher of objects as web pages.
@@ -821,7 +821,7 @@
     assert isinstance(request, WebServiceClientRequest)
     # Zope wrongly encodes any form element that doesn't look like a file,
     # so re-fetch the file content if it has been encoded.
-    if request and request.form.has_key(field_name) and isinstance(
+    if request and field_name in request.form and isinstance(
         request.form[field_name], unicode):
         request._environ['wsgi.input'].seek(0)
         fs = FieldStorage(fp=request._body_instream, environ=request._environ)

=== modified file 'lib/lp/soyuz/doc/soyuz-upload.txt'
--- lib/lp/soyuz/doc/soyuz-upload.txt	2016-02-04 19:46:52 +0000
+++ lib/lp/soyuz/doc/soyuz-upload.txt	2016-02-08 12:47:55 +0000
@@ -54,11 +54,11 @@
     >>> for changes_filepath in changes:
     ...     tf = parse_tagfile(changes_filepath)
     ...
-    ...     if tf.has_key("Source"):
+    ...     if "Source" in tf:
     ...         package_names.append(tf["Source"])
     ...
     ...     send_filepaths = [changes_filepath]
-    ...     if tf.has_key("Files"):
+    ...     if "Files" in tf:
     ...         send_filepaths.extend(
     ...             [os.path.join(test_files_dir, line.split()[-1])
     ...              for line in tf["Files"].splitlines() if line])


Follow ups