Merge ~cjwatson/launchpad:next-builtin into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 7f354e612a7693109ff83a088f0a78ae982765b1
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:next-builtin
Merge into: launchpad:master
Diff against target: 1153 lines (+128/-119)
51 files modified
lib/lp/answers/doc/karma.txt (+10/-10)
lib/lp/answers/tests/emailinterface.txt (+3/-3)
lib/lp/app/browser/launchpad.py (+2/-2)
lib/lp/bugs/browser/tests/test_cve.py (+2/-1)
lib/lp/bugs/browser/widgets/bugtask.py (+1/-1)
lib/lp/bugs/doc/bugcomment.txt (+1/-1)
lib/lp/bugs/externalbugtracker/mantis.py (+1/-1)
lib/lp/bugs/externalbugtracker/roundup.py (+1/-1)
lib/lp/bugs/externalbugtracker/trac.py (+1/-1)
lib/lp/bugs/scripts/debbugs.py (+4/-2)
lib/lp/bugs/scripts/tests/test_bugnotification.py (+6/-6)
lib/lp/code/browser/sourcepackagerecipe.py (+1/-1)
lib/lp/code/browser/tests/test_branchlisting.py (+2/-2)
lib/lp/code/browser/tests/test_branchmergeproposal.py (+2/-2)
lib/lp/code/browser/tests/test_sourcepackagerecipe.py (+6/-6)
lib/lp/code/doc/branch.txt (+1/-1)
lib/lp/code/doc/codeimport-result.txt (+3/-3)
lib/lp/code/model/branchnamespace.py (+1/-1)
lib/lp/code/model/gitlookup.py (+2/-2)
lib/lp/code/model/tests/test_branchcloud.py (+1/-1)
lib/lp/code/model/tests/test_codeimport.py (+6/-6)
lib/lp/code/model/tests/test_revision.py (+4/-4)
lib/lp/code/model/tests/test_revisioncache.py (+2/-2)
lib/lp/code/stories/branches/xx-personproduct-branch-listings.txt (+4/-4)
lib/lp/code/stories/feeds/xx-branch-atom.txt (+1/-1)
lib/lp/code/stories/feeds/xx-revision-atom.txt (+1/-1)
lib/lp/code/tests/codeimporthelpers.py (+1/-1)
lib/lp/code/tests/helpers.py (+3/-3)
lib/lp/code/vocabularies/branch.py (+1/-1)
lib/lp/code/vocabularies/gitrepository.py (+1/-1)
lib/lp/codehosting/scanner/mergedetection.py (+1/-1)
lib/lp/codehosting/sftp.py (+5/-4)
lib/lp/codehosting/vfs/tests/test_branchfs.py (+1/-1)
lib/lp/registry/doc/person-merge.txt (+4/-4)
lib/lp/registry/doc/standing.txt (+1/-1)
lib/lp/registry/tests/test_milestonetag.py (+1/-1)
lib/lp/services/apachelogparser/base.py (+1/-1)
lib/lp/services/doc/propertycache.txt (+1/-1)
lib/lp/services/gpg/tests/test_gpghandler.py (+1/-1)
lib/lp/services/librarianserver/swift.py (+1/-1)
lib/lp/services/mail/tests/mbox_mailer.txt (+10/-10)
lib/lp/services/tests/test_utils.py (+2/-2)
lib/lp/services/twistedsupport/tests/test_task.py (+4/-1)
lib/lp/services/webapp/doc/canonical_url.txt (+5/-5)
lib/lp/services/webapp/errorlog.py (+1/-1)
lib/lp/services/webapp/servers.py (+2/-2)
lib/lp/services/webapp/tests/test_authorization.py (+1/-1)
lib/lp/testing/__init__.py (+3/-3)
lib/lp/testing/factory.py (+3/-3)
lib/lp/translations/browser/tests/test_translationmessage_view.py (+2/-1)
lib/lp/translations/tests/test_potmsgset.py (+3/-2)
Reviewer Review Type Date Requested Status
Thiago F. Pappacena (community) Approve
Review via email: mp+380096@code.launchpad.net

Commit message

Use next(iterator) rather than iterator.next()

To post a comment you must log in.
Revision history for this message
Thiago F. Pappacena (pappacena) :
Revision history for this message
Thiago F. Pappacena (pappacena) wrote :

Added a simple comment, but nothing that blocks this MP.

review: Approve
~cjwatson/launchpad:next-builtin updated
7f354e6... by Colin Watson

Handle Python 3 iterator protocol changes

We now define `__next__` rather than `next`, and use six.Iterator to
smooth over compatibility issues.

Revision history for this message
Colin Watson (cjwatson) :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/answers/doc/karma.txt b/lib/lp/answers/doc/karma.txt
2index 2a978d5..6d45d07 100644
3--- a/lib/lp/answers/doc/karma.txt
4+++ b/lib/lp/answers/doc/karma.txt
5@@ -64,7 +64,7 @@ Creating a question
6 >>> firefox = getUtility(IProductSet)['firefox']
7 >>> firefox_question = firefox.newQuestion(
8 ... title='New question', description='Question description.',
9- ... owner=sample_person, datecreated=now.next())
10+ ... owner=sample_person, datecreated=next(now))
11 Karma added: action=questionasked, product=firefox, person=name12
12
13
14@@ -77,7 +77,7 @@ will usually be called by an automated script.
15 >>> msg = firefox_question.expireQuestion(
16 ... foo_bar, 'Expiring because of inactivity. Reopen if you are '
17 ... 'still having the problem and provide additional information.',
18- ... datecreated=now.next())
19+ ... datecreated=next(now))
20
21
22 Reopening a question
23@@ -85,7 +85,7 @@ Reopening a question
24
25 >>> msg = firefox_question.reopen(
26 ... "Firefox doesn't have any 'Quick Searches' in its bookmarks.",
27- ... datecreated=now.next())
28+ ... datecreated=next(now))
29 Karma added: action=questionreopened, product=firefox, person=name12
30
31
32@@ -94,7 +94,7 @@ Requesting for more information
33
34 >>> msg = firefox_question.requestInfo(
35 ... foo_bar, 'What "Quick Searches" do you want?',
36- ... datecreated=now.next())
37+ ... datecreated=next(now))
38 Karma added: action=questionrequestedinfo, product=firefox, person=name16
39
40
41@@ -103,7 +103,7 @@ Giving back more information
42
43 >>> msg = firefox_question.giveInfo(
44 ... 'The same one than shipped upstreams.',
45- ... datecreated=now.next())
46+ ... datecreated=next(now))
47 Karma added: action=questiongaveinfo, product=firefox, person=name12
48
49
50@@ -112,7 +112,7 @@ Giving an answer to a question
51
52 >>> msg = firefox_question.giveAnswer(
53 ... foo_bar, "Ok, I see what you mean. You need to install them "
54- ... "manually for now.", datecreated=now.next())
55+ ... "manually for now.", datecreated=next(now))
56 Karma added: action=questiongaveanswer, product=firefox, person=name16
57
58
59@@ -121,7 +121,7 @@ Adding a comment
60
61 >>> msg = firefox_question.addComment(
62 ... foo_bar, 'You could also fill a bug about that, if you like.',
63- ... datecreated=now.next())
64+ ... datecreated=next(now))
65 Karma added: action=questioncommentadded, product=firefox, person=name16
66
67
68@@ -134,7 +134,7 @@ receives karma.
69
70 >>> msg = firefox_question.confirmAnswer(
71 ... "Ok, thanks. I'll open a bug about this then.",
72- ... answer=msg, datecreated=now.next())
73+ ... answer=msg, datecreated=next(now))
74 Karma added: action=questionansweraccepted, product=firefox, person=name12
75 Karma added: action=questionanswered, product=firefox, person=name16
76
77@@ -156,7 +156,7 @@ We do not grant karma for status change made outside of workflow:
78 >>> from lp.answers.enums import QuestionStatus
79 >>> msg = firefox_question.setStatus(
80 ... foo_bar, QuestionStatus.OPEN, 'That rejection was an error.',
81- ... datecreated=now.next())
82+ ... datecreated=next(now))
83
84
85 Changing the title of a question
86@@ -205,7 +205,7 @@ persons who were awarded it in the past.
87 >>> msg = firefox_question.giveAnswer(
88 ... sample_person, "I was able to import some by following the "
89 ... "instructions on http://tinyurl.com/cyus4",
90- ... datecreated=now.next())
91+ ... datecreated=next(now))
92
93
94 Creating a FAQ
95diff --git a/lib/lp/answers/tests/emailinterface.txt b/lib/lp/answers/tests/emailinterface.txt
96index 8718ea1..f30e23e 100644
97--- a/lib/lp/answers/tests/emailinterface.txt
98+++ b/lib/lp/answers/tests/emailinterface.txt
99@@ -38,7 +38,7 @@ AnswerTrackerHandler.
100 ... lines = ['From: %s' % from_addr]
101 ... to_addr = 'question%s@answers.launchpad.net' % question_id
102 ... lines.append('To: %s' % to_addr)
103- ... date = mktime_tz(now.next().utctimetuple() + (0, ))
104+ ... date = mktime_tz(next(now).utctimetuple() + (0, ))
105 ... lines.append('Date: %s' % formatdate(date))
106 ... msgid = make_msgid()
107 ... lines.append('Message-Id: %s' % msgid)
108@@ -116,7 +116,7 @@ possibilities for the user.
109 ... question = ubuntu.newQuestion(
110 ... no_priv, 'Unable to boot installer',
111 ... "I've tried installing Ubuntu on a Mac. But the installer "
112- ... "never boots.", datecreated=now.next())
113+ ... "never boots.", datecreated=next(now))
114 ... question_id = question.id
115
116 # We need to refetch the question, since a new transaction was started.
117@@ -127,7 +127,7 @@ possibilities for the user.
118 >>> def setQuestionStatus(question, new_status):
119 ... login('foo.bar@canonical.com')
120 ... question.setStatus(foo_bar, new_status, 'Status Change',
121- ... datecreated=now.next())
122+ ... datecreated=next(now))
123 ... login('no-priv@canonical.com')
124
125 Message From the Question Owner
126diff --git a/lib/lp/app/browser/launchpad.py b/lib/lp/app/browser/launchpad.py
127index d12c849..4aa9a39 100644
128--- a/lib/lp/app/browser/launchpad.py
129+++ b/lib/lp/app/browser/launchpad.py
130@@ -271,9 +271,9 @@ class Hierarchy(LaunchpadView):
131 """The objects for which we want breadcrumbs."""
132 # Start the chain with the deepest object that has a breadcrumb.
133 try:
134- objects = [(
135+ objects = [next((
136 obj for obj in reversed(self.request.traversed_objects)
137- if IBreadcrumb(obj, None)).next()]
138+ if IBreadcrumb(obj, None)))]
139 except StopIteration:
140 return []
141 # Now iterate. If an object has a breadcrumb, it can override
142diff --git a/lib/lp/bugs/browser/tests/test_cve.py b/lib/lp/bugs/browser/tests/test_cve.py
143index e0b485e..ee760e3 100644
144--- a/lib/lp/bugs/browser/tests/test_cve.py
145+++ b/lib/lp/bugs/browser/tests/test_cve.py
146@@ -3,6 +3,7 @@
147
148 """CVE related tests."""
149
150+from functools import partial
151 from operator import attrgetter
152 import re
153
154@@ -35,7 +36,7 @@ class TestCVEReportView(TestCaseWithFactory):
155 self.resolved_bugtasks = []
156 self.unresolved_bugtasks = []
157 self.cves = {}
158- self.getCVE = self.cveGenerator().next
159+ self.getCVE = partial(next, self.cveGenerator())
160 with person_logged_in(distroseries.owner):
161 for status in RESOLVED_BUGTASK_STATUSES:
162 tasks, cves = self.makeBugTasksWithCve(status, distroseries)
163diff --git a/lib/lp/bugs/browser/widgets/bugtask.py b/lib/lp/bugs/browser/widgets/bugtask.py
164index b17d19f..2f086b2 100644
165--- a/lib/lp/bugs/browser/widgets/bugtask.py
166+++ b/lib/lp/bugs/browser/widgets/bugtask.py
167@@ -384,7 +384,7 @@ class BugTaskBugWatchWidget(RadioWidget):
168 and len(self.vocabulary) > 0
169 and self.context.required):
170 # Grab the first item from the iterator:
171- values = [iter(self.vocabulary).next().value]
172+ values = [next(iter(self.vocabulary)).value]
173 elif value != self.context.missing_value:
174 values = [value]
175 else:
176diff --git a/lib/lp/bugs/doc/bugcomment.txt b/lib/lp/bugs/doc/bugcomment.txt
177index f98907b..a6e9c1c 100644
178--- a/lib/lp/bugs/doc/bugcomment.txt
179+++ b/lib/lp/bugs/doc/bugcomment.txt
180@@ -270,7 +270,7 @@ We'll create an example bug with 9 comments.
181 >>> def add_comments(bug, how_many):
182 ... bug_message_set = getUtility(IBugMessageSet)
183 ... for i in range(how_many):
184- ... num = comment_counter.next()
185+ ... num = next(comment_counter)
186 ... bug_message_set.createMessage(
187 ... "Comment %d" % num, bug, bug.owner,
188 ... "Something or other #%d" % num)
189diff --git a/lib/lp/bugs/externalbugtracker/mantis.py b/lib/lp/bugs/externalbugtracker/mantis.py
190index 9cb8203..6021f37 100644
191--- a/lib/lp/bugs/externalbugtracker/mantis.py
192+++ b/lib/lp/bugs/externalbugtracker/mantis.py
193@@ -140,7 +140,7 @@ class MantisBugBatchParser:
194 # it because different Mantis instances have different header
195 # ordering and even different columns in the export.
196 try:
197- headers = [h.lower() for h in reader.next()]
198+ headers = [h.lower() for h in next(reader)]
199 except StopIteration:
200 raise UnparsableBugData("Missing header line")
201 missing_headers = [
202diff --git a/lib/lp/bugs/externalbugtracker/roundup.py b/lib/lp/bugs/externalbugtracker/roundup.py
203index f862aec..66f46ca 100644
204--- a/lib/lp/bugs/externalbugtracker/roundup.py
205+++ b/lib/lp/bugs/externalbugtracker/roundup.py
206@@ -219,7 +219,7 @@ class Roundup(ExternalBugTracker):
207 bug_id = int(bug_id)
208 query_url = self.getSingleBugExportURL(bug_id)
209 reader = csv.DictReader(self._getPage(query_url).iter_lines())
210- return (bug_id, reader.next())
211+ return (bug_id, next(reader))
212
213 def getRemoteBugBatch(self, bug_ids):
214 """See `ExternalBugTracker`"""
215diff --git a/lib/lp/bugs/externalbugtracker/trac.py b/lib/lp/bugs/externalbugtracker/trac.py
216index d10d8f2..ab36b7e 100644
217--- a/lib/lp/bugs/externalbugtracker/trac.py
218+++ b/lib/lp/bugs/externalbugtracker/trac.py
219@@ -151,7 +151,7 @@ class Trac(ExternalBugTracker):
220 # We read the remote bugs into a list so that we can check that
221 # the data we're getting back from the remote server are valid.
222 csv_reader = csv.DictReader(self._getPage(query_url).iter_lines())
223- remote_bugs = [csv_reader.next()]
224+ remote_bugs = [next(csv_reader)]
225
226 # We consider the data we're getting from the remote server to
227 # be valid if there is an ID field and a status field in the CSV
228diff --git a/lib/lp/bugs/scripts/debbugs.py b/lib/lp/bugs/scripts/debbugs.py
229index c632743..90de42f 100644
230--- a/lib/lp/bugs/scripts/debbugs.py
231+++ b/lib/lp/bugs/scripts/debbugs.py
232@@ -8,6 +8,8 @@ import os
233 import re
234 import subprocess
235
236+import six
237+
238
239 class Bug:
240 def __init__(self, db, id, package=None, date=None, status=None,
241@@ -97,7 +99,7 @@ class Database:
242 self.debbugs_pl = debbugs_pl
243 self.subdir = subdir
244
245- class bug_iterator:
246+ class bug_iterator(six.Iterator):
247 index_record = re.compile(
248 r'^(?P<package>\S+) (?P<bugid>\d+) (?P<date>\d+) (?P<status>\w+) '
249 r'\[(?P<originator>.*)\] (?P<severity>\w+)(?: (?P<tags>.*))?$')
250@@ -107,7 +109,7 @@ class Database:
251 self.index = open(os.path.join(self.db.root, 'index/index.db'))
252 self.filter = filter
253
254- def next(self):
255+ def __next__(self):
256 line = self.index.readline()
257 if not line:
258 raise StopIteration
259diff --git a/lib/lp/bugs/scripts/tests/test_bugnotification.py b/lib/lp/bugs/scripts/tests/test_bugnotification.py
260index 1b3f4cb..734b68f 100644
261--- a/lib/lp/bugs/scripts/tests/test_bugnotification.py
262+++ b/lib/lp/bugs/scripts/tests/test_bugnotification.py
263@@ -427,7 +427,7 @@ class TestGetEmailNotifications(TestCase):
264 # Now we create the generator, start it, and then close it, triggering
265 # a GeneratorExit exception inside the generator.
266 email_notifications = get_email_notifications(notifications)
267- email_notifications.next()
268+ next(email_notifications)
269 email_notifications.close()
270
271 # Verify that no "Error while building email notifications." is logged.
272@@ -706,7 +706,7 @@ class EmailNotificationsBugMixin:
273 def test_change_seen(self):
274 # A smoketest.
275 self.change(self.old, self.new)
276- message, body = self.get_messages().next()
277+ message, body = next(self.get_messages())
278 self.assertThat(body, Contains(self.unexpected_text))
279
280 def test_undone_change_sends_no_emails(self):
281@@ -718,7 +718,7 @@ class EmailNotificationsBugMixin:
282 self.change(self.old, self.new)
283 self.change(self.new, self.old)
284 self.change_other()
285- message, body = self.get_messages().next()
286+ message, body = next(self.get_messages())
287 self.assertThat(body, Not(Contains(self.unexpected_text)))
288
289 def test_multiple_undone_changes_sends_no_emails(self):
290@@ -761,7 +761,7 @@ class EmailNotificationsBugTaskMixin(EmailNotificationsBugMixin):
291 self.bug.addTask(self.product_owner, product2)
292 self.change(self.old, self.new, index=0)
293 self.change(self.new, self.old, index=1)
294- message, body = self.get_messages().next()
295+ message, body = next(self.get_messages())
296 self.assertThat(body, Contains(self.unexpected_text))
297
298
299@@ -775,7 +775,7 @@ class EmailNotificationsAddedRemovedMixin:
300
301 def test_added_seen(self):
302 self.add(self.old)
303- message, body = self.get_messages().next()
304+ message, body = next(self.get_messages())
305 self.assertThat(body, Contains(self.added_message))
306
307 def test_added_removed_sends_no_emails(self):
308@@ -791,7 +791,7 @@ class EmailNotificationsAddedRemovedMixin:
309 def test_added_another_removed_sends_emails(self):
310 self.add(self.old)
311 self.remove(self.new)
312- message, body = self.get_messages().next()
313+ message, body = next(self.get_messages())
314 self.assertThat(body, Contains(self.added_message))
315 self.assertThat(body, Contains(self.removed_message))
316
317diff --git a/lib/lp/code/browser/sourcepackagerecipe.py b/lib/lp/code/browser/sourcepackagerecipe.py
318index 482d892..5ae3eee 100644
319--- a/lib/lp/code/browser/sourcepackagerecipe.py
320+++ b/lib/lp/code/browser/sourcepackagerecipe.py
321@@ -755,7 +755,7 @@ class SourcePackageRecipeAddView(RecipeRelatedBranchesMixin,
322 yield "%s-daily" % branch_target_name
323 counter = itertools.count(1)
324 while True:
325- yield "%s-daily-%s" % (branch_target_name, counter.next())
326+ yield "%s-daily-%s" % (branch_target_name, next(counter))
327
328 def _find_unused_name(self, owner):
329 # Grab the last path element of the branch target path.
330diff --git a/lib/lp/code/browser/tests/test_branchlisting.py b/lib/lp/code/browser/tests/test_branchlisting.py
331index 8598090..5aed624 100644
332--- a/lib/lp/code/browser/tests/test_branchlisting.py
333+++ b/lib/lp/code/browser/tests/test_branchlisting.py
334@@ -123,7 +123,7 @@ class TestPersonOwnedBranchesView(TestCaseWithFactory,
335 self.branches = [
336 self.factory.makeProductBranch(
337 product=self.bambam, owner=self.barney,
338- date_created=time_gen.next())
339+ date_created=next(time_gen))
340 for i in range(10)]
341 self.bug = self.factory.makeBug()
342 self.bug.linkBranch(self.branches[0], self.barney)
343@@ -459,7 +459,7 @@ class TestGroupedDistributionSourcePackageBranchesView(TestCaseWithFactory):
344 self.factory.makePackageBranch(
345 distroseries=distroseries,
346 sourcepackagename=self.sourcepackagename,
347- date_created=time_gen.next())
348+ date_created=next(time_gen))
349 for i in range(branch_count)]
350
351 official = []
352diff --git a/lib/lp/code/browser/tests/test_branchmergeproposal.py b/lib/lp/code/browser/tests/test_branchmergeproposal.py
353index bf5bdb3..2e3055a 100644
354--- a/lib/lp/code/browser/tests/test_branchmergeproposal.py
355+++ b/lib/lp/code/browser/tests/test_branchmergeproposal.py
356@@ -322,13 +322,13 @@ class TestBranchMergeProposalVoteView(TestCaseWithFactory):
357 owner=reviewer,
358 subject=self.factory.getUniqueString('subject'),
359 vote=vote,
360- _date_created=self.date_generator.next())
361+ _date_created=next(self.date_generator))
362
363 def _nominateReviewer(self, reviewer, registrant):
364 """Nominate a reviewer for the merge proposal."""
365 self.bmp.nominateReviewer(
366 reviewer=reviewer, registrant=registrant,
367- _date_created=self.date_generator.next())
368+ _date_created=next(self.date_generator))
369
370 def testNoVotes(self):
371 # No votes should return empty lists
372diff --git a/lib/lp/code/browser/tests/test_sourcepackagerecipe.py b/lib/lp/code/browser/tests/test_sourcepackagerecipe.py
373index 97c7a1a..3b1124a 100644
374--- a/lib/lp/code/browser/tests/test_sourcepackagerecipe.py
375+++ b/lib/lp/code/browser/tests/test_sourcepackagerecipe.py
376@@ -1362,12 +1362,12 @@ class TestSourcePackageRecipeViewMixin:
377 # use id as the ordering attribute and lower ids mean created earlier.
378 date_gen = time_counter(
379 datetime(2010, 3, 16, tzinfo=UTC), timedelta(days=1))
380- build1 = self.makeBuildJob(recipe, date_gen.next())
381- build2 = self.makeBuildJob(recipe, date_gen.next())
382- build3 = self.makeBuildJob(recipe, date_gen.next())
383- build4 = self.makeBuildJob(recipe, date_gen.next())
384- build5 = self.makeBuildJob(recipe, date_gen.next())
385- build6 = self.makeBuildJob(recipe, date_gen.next())
386+ build1 = self.makeBuildJob(recipe, next(date_gen))
387+ build2 = self.makeBuildJob(recipe, next(date_gen))
388+ build3 = self.makeBuildJob(recipe, next(date_gen))
389+ build4 = self.makeBuildJob(recipe, next(date_gen))
390+ build5 = self.makeBuildJob(recipe, next(date_gen))
391+ build6 = self.makeBuildJob(recipe, next(date_gen))
392 view = SourcePackageRecipeView(recipe, None)
393 self.assertEqual(
394 [build6, build5, build4, build3, build2, build1],
395diff --git a/lib/lp/code/doc/branch.txt b/lib/lp/code/doc/branch.txt
396index e9c654c..c1142c0 100644
397--- a/lib/lp/code/doc/branch.txt
398+++ b/lib/lp/code/doc/branch.txt
399@@ -193,7 +193,7 @@ order.
400 ... """Create """
401 ... new_branch = factory.makeProductBranch(
402 ... branch_type=branch_type, owner=owner, product=product,
403- ... name=name, date_created=time_generator.next())
404+ ... name=name, date_created=next(time_generator))
405 ... new_branch.last_scanned = new_branch.date_created
406
407 >>> make_new_scanned_branch('oldest')
408diff --git a/lib/lp/code/doc/codeimport-result.txt b/lib/lp/code/doc/codeimport-result.txt
409index 39fe511..fd0b617 100644
410--- a/lib/lp/code/doc/codeimport-result.txt
411+++ b/lib/lp/code/doc/codeimport-result.txt
412@@ -53,7 +53,7 @@ Then create a result object.
413 >>> from lp.code.enums import CodeImportResultStatus
414 >>> new_result = factory.makeCodeImportResult(
415 ... sample_import, result_status=CodeImportResultStatus.SUCCESS,
416- ... date_started=time_source.next(), log_excerpt=log_excerpt,
417+ ... date_started=next(time_source), log_excerpt=log_excerpt,
418 ... log_alias=log_alias, machine=odin)
419 >>> verifyObject(ICodeImportResult, new_result)
420 True
421@@ -95,9 +95,9 @@ method works as expected.
422
423 >>> oldest_result = new_result
424 >>> middle_result = factory.makeCodeImportResult(
425- ... sample_import, date_started = time_source.next())
426+ ... sample_import, date_started = next(time_source))
427 >>> newest_result = factory.makeCodeImportResult(
428- ... sample_import, date_started = time_source.next())
429+ ... sample_import, date_started = next(time_source))
430
431 Results for other imports of course should not be present in the
432 results, so we should create one of those just to be sure that it's
433diff --git a/lib/lp/code/model/branchnamespace.py b/lib/lp/code/model/branchnamespace.py
434index 33f3305..95f70fc 100644
435--- a/lib/lp/code/model/branchnamespace.py
436+++ b/lib/lp/code/model/branchnamespace.py
437@@ -489,7 +489,7 @@ class BranchNamespaceSet:
438
439 def get_next_segment():
440 try:
441- result = segments.next()
442+ result = next(segments)
443 except StopIteration:
444 raise InvalidNamespace('/'.join(traversed_segments))
445 if result is None:
446diff --git a/lib/lp/code/model/gitlookup.py b/lib/lp/code/model/gitlookup.py
447index 9c01af4..29efe5f 100644
448--- a/lib/lp/code/model/gitlookup.py
449+++ b/lib/lp/code/model/gitlookup.py
450@@ -255,14 +255,14 @@ class DistributionOCIProjectGitTraversable(_BaseGitTraversable):
451 ociprojectname=self.context.ociprojectname)
452
453
454-class SegmentIterator:
455+class SegmentIterator(six.Iterator):
456 """An iterator that remembers the elements it has traversed."""
457
458 def __init__(self, iterator):
459 self._iterator = iterator
460 self.traversed = []
461
462- def next(self):
463+ def __next__(self):
464 segment = six.ensure_text(next(self._iterator), encoding="US-ASCII")
465 self.traversed.append(segment)
466 return segment
467diff --git a/lib/lp/code/model/tests/test_branchcloud.py b/lib/lp/code/model/tests/test_branchcloud.py
468index f0e8038..6c9cfbf 100644
469--- a/lib/lp/code/model/tests/test_branchcloud.py
470+++ b/lib/lp/code/model/tests/test_branchcloud.py
471@@ -119,7 +119,7 @@ class TestBranchCloud(TestCaseWithFactory):
472 store = Store.of(product)
473 for i in range(4):
474 revision = self.factory.makeRevision(
475- revision_date=date_generator.next())
476+ revision_date=next(date_generator))
477 cache = RevisionCache(revision)
478 cache.product = product
479 store.add(cache)
480diff --git a/lib/lp/code/model/tests/test_codeimport.py b/lib/lp/code/model/tests/test_codeimport.py
481index 1e36b30..a57f79e 100644
482--- a/lib/lp/code/model/tests/test_codeimport.py
483+++ b/lib/lp/code/model/tests/test_codeimport.py
484@@ -532,11 +532,11 @@ class TestCodeImportResultsAttribute(TestCodeImportBase):
485 origin=datetime(2007, 9, 9, 12, tzinfo=pytz.UTC),
486 delta=timedelta(days=1))
487 first = self.factory.makeCodeImportResult(
488- self.code_import, date_started=when.next())
489+ self.code_import, date_started=next(when))
490 second = self.factory.makeCodeImportResult(
491- self.code_import, date_started=when.next())
492+ self.code_import, date_started=next(when))
493 third = self.factory.makeCodeImportResult(
494- self.code_import, date_started=when.next())
495+ self.code_import, date_started=next(when))
496 self.assertTrue(first.date_job_started < second.date_job_started)
497 self.assertTrue(second.date_job_started < third.date_job_started)
498 results = list(self.code_import.results)
499@@ -552,11 +552,11 @@ class TestCodeImportResultsAttribute(TestCodeImportBase):
500 origin=datetime(2007, 9, 11, 12, tzinfo=pytz.UTC),
501 delta=timedelta(days=-1))
502 first = self.factory.makeCodeImportResult(
503- self.code_import, date_started=when.next())
504+ self.code_import, date_started=next(when))
505 second = self.factory.makeCodeImportResult(
506- self.code_import, date_started=when.next())
507+ self.code_import, date_started=next(when))
508 third = self.factory.makeCodeImportResult(
509- self.code_import, date_started=when.next())
510+ self.code_import, date_started=next(when))
511 self.assertTrue(first.date_job_started > second.date_job_started)
512 self.assertTrue(second.date_job_started > third.date_job_started)
513 results = list(self.code_import.results)
514diff --git a/lib/lp/code/model/tests/test_revision.py b/lib/lp/code/model/tests/test_revision.py
515index 5976f4e..67fd745 100644
516--- a/lib/lp/code/model/tests/test_revision.py
517+++ b/lib/lp/code/model/tests/test_revision.py
518@@ -369,7 +369,7 @@ class GetPublicRevisionsTestCase(TestCaseWithFactory):
519 def _makeRevision(self, revision_date=None):
520 """Make a revision using the date generator."""
521 if revision_date is None:
522- revision_date = self.date_generator.next()
523+ revision_date = next(self.date_generator)
524 return self.factory.makeRevision(
525 revision_date=revision_date)
526
527@@ -477,7 +477,7 @@ class TestGetPublicRevisionsForPerson(GetPublicRevisionsTestCase,
528
529 `author` defaults to self.author if not set."""
530 if revision_date is None:
531- revision_date = self.date_generator.next()
532+ revision_date = next(self.date_generator)
533 if author is None:
534 author = self.author
535 return self.factory.makeRevision(
536@@ -955,7 +955,7 @@ class TestPruneRevisionCache(RevisionCacheTestCase):
537 delta=timedelta(days=2))
538 for i in range(4):
539 revision = self.factory.makeRevision(
540- revision_date=date_generator.next())
541+ revision_date=next(date_generator))
542 cache = RevisionCache(revision)
543 self.store.add(cache)
544 RevisionSet.pruneRevisionCache(5)
545@@ -968,7 +968,7 @@ class TestPruneRevisionCache(RevisionCacheTestCase):
546 delta=timedelta(days=2))
547 for i in range(4):
548 revision = self.factory.makeRevision(
549- revision_date=date_generator.next())
550+ revision_date=next(date_generator))
551 cache = RevisionCache(revision)
552 self.store.add(cache)
553 RevisionSet.pruneRevisionCache(1)
554diff --git a/lib/lp/code/model/tests/test_revisioncache.py b/lib/lp/code/model/tests/test_revisioncache.py
555index 00e60d5..2f5ea2d 100644
556--- a/lib/lp/code/model/tests/test_revisioncache.py
557+++ b/lib/lp/code/model/tests/test_revisioncache.py
558@@ -114,7 +114,7 @@ class TestRevisionCache(TestCaseWithFactory):
559 # query is the reverse order.
560 revisions = [
561 self.makeCachedRevision(
562- revision=self.factory.makeRevision(revision_date=tc.next()))
563+ revision=self.factory.makeRevision(revision_date=next(tc)))
564 for i in range(4)]
565 revisions.reverse()
566 cache = getUtility(IRevisionCache)
567@@ -142,7 +142,7 @@ class TestRevisionCache(TestCaseWithFactory):
568 # Make four cached revisions spanning 33, 31, 29, and 27 days ago.
569 for i in range(4):
570 self.makeCachedRevision(
571- revision=self.factory.makeRevision(revision_date=tc.next()))
572+ revision=self.factory.makeRevision(revision_date=next(tc)))
573 cache = getUtility(IRevisionCache)
574 self.assertEqual(2, cache.count())
575
576diff --git a/lib/lp/code/stories/branches/xx-personproduct-branch-listings.txt b/lib/lp/code/stories/branches/xx-personproduct-branch-listings.txt
577index b9c31c5..6275b92 100644
578--- a/lib/lp/code/stories/branches/xx-personproduct-branch-listings.txt
579+++ b/lib/lp/code/stories/branches/xx-personproduct-branch-listings.txt
580@@ -27,14 +27,14 @@ that only the fooix branches are shown.
581 ... datetime(2007, 12, 1, tzinfo=pytz.UTC), timedelta(days=1))
582 >>> branch = factory.makeProductBranch(
583 ... owner=eric, product=fooix, name="testing",
584- ... date_created=date_generator.next())
585+ ... date_created=next(date_generator))
586 >>> branch = factory.makeProductBranch(
587 ... owner=eric, product=fooix, name="feature",
588- ... date_created=date_generator.next())
589+ ... date_created=next(date_generator))
590 >>> branch = factory.makeAnyBranch(
591- ... owner=eric, date_created=date_generator.next())
592+ ... owner=eric, date_created=next(date_generator))
593 >>> branch = factory.makeAnyBranch(
594- ... owner=eric, date_created=date_generator.next())
595+ ... owner=eric, date_created=next(date_generator))
596 >>> logout()
597
598 >>> browser.open('http://code.launchpad.test/~eric/fooix')
599diff --git a/lib/lp/code/stories/feeds/xx-branch-atom.txt b/lib/lp/code/stories/feeds/xx-branch-atom.txt
600index 7c91bca..c8e3628 100644
601--- a/lib/lp/code/stories/feeds/xx-branch-atom.txt
602+++ b/lib/lp/code/stories/feeds/xx-branch-atom.txt
603@@ -21,7 +21,7 @@ by asking BeautifulSoup to use lxml.
604 >>> def make_branch(owner, product, name):
605 ... global factory, date_generator
606 ... factory.makeProductBranch(name=name, product=product,
607- ... owner=owner, date_created=date_generator.next())
608+ ... owner=owner, date_created=next(date_generator))
609 >>> mike = factory.makePerson(name='mike', displayname='Mike Murphy')
610 >>> mary = factory.makePerson(name='mary', displayname='Mary Murphy')
611 >>> projectgroup = factory.makeProject(name='oh-man', displayname='Oh Man')
612diff --git a/lib/lp/code/stories/feeds/xx-revision-atom.txt b/lib/lp/code/stories/feeds/xx-revision-atom.txt
613index 0fadb05..3079a35 100644
614--- a/lib/lp/code/stories/feeds/xx-revision-atom.txt
615+++ b/lib/lp/code/stories/feeds/xx-revision-atom.txt
616@@ -37,7 +37,7 @@ by asking BeautifulSoup to use lxml.
617 ... global factory, date_generator
618 ... return factory.makeRevision(
619 ... author=removeSecurityProxy(author).preferredemail.email,
620- ... revision_date=date_generator.next(),
621+ ... revision_date=next(date_generator),
622 ... rev_id=rev_id, log_body=log_body)
623 >>> ignored = fooey_branch.createBranchRevision(
624 ... 1, makeRevision(
625diff --git a/lib/lp/code/tests/codeimporthelpers.py b/lib/lp/code/tests/codeimporthelpers.py
626index 34110cb..3e177f6 100644
627--- a/lib/lp/code/tests/codeimporthelpers.py
628+++ b/lib/lp/code/tests/codeimporthelpers.py
629@@ -132,5 +132,5 @@ def make_all_result_types(code_import, factory, machine, start, count):
630 for result_status in sorted(CodeImportResultStatus.items)[
631 start:start + count]:
632 factory.makeCodeImportResult(
633- code_import, result_status, start_dates.next(), end_dates.next(),
634+ code_import, result_status, next(start_dates), next(end_dates),
635 machine=machine)
636diff --git a/lib/lp/code/tests/helpers.py b/lib/lp/code/tests/helpers.py
637index 2955528..46f12ed 100644
638--- a/lib/lp/code/tests/helpers.py
639+++ b/lib/lp/code/tests/helpers.py
640@@ -160,7 +160,7 @@ def consistent_branch_names():
641 yield name
642 index = count(1)
643 while True:
644- yield "branch-%s" % index.next()
645+ yield "branch-%s" % next(index)
646
647
648 def make_package_branches(factory, series, sourcepackagename, branch_count,
649@@ -180,8 +180,8 @@ def make_package_branches(factory, series, sourcepackagename, branch_count,
650 factory.makePackageBranch(
651 distroseries=series,
652 sourcepackagename=sourcepackagename,
653- date_created=time_gen.next(),
654- name=branch_names.next(), owner=owner, registrant=registrant)
655+ date_created=next(time_gen),
656+ name=next(branch_names), owner=owner, registrant=registrant)
657 for i in range(branch_count)]
658
659 official = []
660diff --git a/lib/lp/code/vocabularies/branch.py b/lib/lp/code/vocabularies/branch.py
661index bd828ae..db4a39e 100644
662--- a/lib/lp/code/vocabularies/branch.py
663+++ b/lib/lp/code/vocabularies/branch.py
664@@ -47,7 +47,7 @@ class BranchVocabulary(SQLObjectVocabularyBase):
665 """See `IVocabularyTokenized`."""
666 search_results = self.searchForTerms(token)
667 if search_results.count() == 1:
668- return iter(search_results).next()
669+ return next(iter(search_results))
670 raise LookupError(token)
671
672 def searchForTerms(self, query=None, vocab_filter=None):
673diff --git a/lib/lp/code/vocabularies/gitrepository.py b/lib/lp/code/vocabularies/gitrepository.py
674index 80f6524..0fc86d0 100644
675--- a/lib/lp/code/vocabularies/gitrepository.py
676+++ b/lib/lp/code/vocabularies/gitrepository.py
677@@ -43,7 +43,7 @@ class GitRepositoryVocabulary(StormVocabularyBase):
678 """See `IVocabularyTokenized`."""
679 search_results = self.searchForTerms(token)
680 if search_results.count() == 1:
681- return iter(search_results).next()
682+ return next(iter(search_results))
683 raise LookupError(token)
684
685 def searchForTerms(self, query=None, vocab_filter=None):
686diff --git a/lib/lp/codehosting/scanner/mergedetection.py b/lib/lp/codehosting/scanner/mergedetection.py
687index 0e5dcd5..c73cd52 100644
688--- a/lib/lp/codehosting/scanner/mergedetection.py
689+++ b/lib/lp/codehosting/scanner/mergedetection.py
690@@ -127,7 +127,7 @@ def find_merged_revno(merge_sorted, tip_rev_id):
691 iterator = iter(merge_sorted)
692 while True:
693 try:
694- rev_id, depth, revno, ignored = iterator.next()
695+ rev_id, depth, revno, ignored = next(iterator)
696 except StopIteration:
697 break
698 if depth == 0:
699diff --git a/lib/lp/codehosting/sftp.py b/lib/lp/codehosting/sftp.py
700index 51d42e7..3c9dfb7 100644
701--- a/lib/lp/codehosting/sftp.py
702+++ b/lib/lp/codehosting/sftp.py
703@@ -31,6 +31,7 @@ from breezy import (
704 )
705 from breezy.transport.local import LocalTransport
706 from lazr.sshserver.sftp import FileIsADirectory
707+import six
708 from twisted.conch.interfaces import (
709 ISFTPFile,
710 ISFTPServer,
711@@ -97,7 +98,7 @@ def with_sftp_error(func):
712 return util.mergeFunctionMetadata(func, decorator)
713
714
715-class DirectoryListing:
716+class DirectoryListing(six.Iterator):
717 """Class to satisfy openDirectory return interface.
718
719 openDirectory returns an iterator -- with a `close` method. Hence
720@@ -110,8 +111,8 @@ class DirectoryListing:
721 def __iter__(self):
722 return self
723
724- def next(self):
725- return self.iter.next()
726+ def __next__(self):
727+ return next(self.iter)
728
729 def close(self):
730 # I can't believe we had to implement a whole class just to
731@@ -191,7 +192,7 @@ class TransportSFTPFile:
732 self._escaped_path, [(offset, length)])
733
734 def get_first_chunk(read_things):
735- return read_things.next()[1]
736+ return next(read_things)[1]
737
738 def handle_short_read(failure):
739 """Handle short reads by reading what was available.
740diff --git a/lib/lp/codehosting/vfs/tests/test_branchfs.py b/lib/lp/codehosting/vfs/tests/test_branchfs.py
741index 0aa7fe7..9e0896b 100644
742--- a/lib/lp/codehosting/vfs/tests/test_branchfs.py
743+++ b/lib/lp/codehosting/vfs/tests/test_branchfs.py
744@@ -607,7 +607,7 @@ class LaunchpadTransportTests:
745 [(3, 2)])
746
747 def get_chunk(generator):
748- return generator.next()[1]
749+ return next(generator)[1]
750 deferred.addCallback(get_chunk)
751 return deferred.addCallback(self.assertEqual, data[3:5])
752
753diff --git a/lib/lp/registry/doc/person-merge.txt b/lib/lp/registry/doc/person-merge.txt
754index 55d627a..ffb12b9 100644
755--- a/lib/lp/registry/doc/person-merge.txt
756+++ b/lib/lp/registry/doc/person-merge.txt
757@@ -294,7 +294,7 @@ create, and then delete, the needed two people.
758
759 First, we will test a merge where there is no decoration.
760
761- >>> winner, loser = endless_supply_of_players.next()
762+ >>> winner, loser = next(endless_supply_of_players)
763 >>> print decorator_refs(store, winner, loser)
764 <BLANKLINE>
765
766@@ -316,7 +316,7 @@ There should still be no columns that reference the winner or loser.
767 OK, now, this time, we will add some decorator information to the winner
768 but not the loser.
769
770- >>> winner, loser = endless_supply_of_players.next()
771+ >>> winner, loser = next(endless_supply_of_players)
772 >>> winner.setLocation(None, None, 'America/Santiago', winner)
773 >>> print decorator_refs(store, winner, loser)
774 winner, winner,
775@@ -333,7 +333,7 @@ the winner:
776 This time, we will have a decorator for the person that is being merged
777 INTO another person, but nothing on the target person.
778
779- >>> winner, loser = endless_supply_of_players.next()
780+ >>> winner, loser = next(endless_supply_of_players)
781 >>> loser.setLocation(None, None, 'America/Santiago', loser)
782 >>> print decorator_refs(store, winner, loser)
783 loser, loser,
784@@ -352,7 +352,7 @@ to_person and the from_person. We expect that the from_person record
785 will remain as noise but non-unique columns will have been updated to
786 point to the winner, and the to_person will be unaffected.
787
788- >>> winner, loser = endless_supply_of_players.next()
789+ >>> winner, loser = next(endless_supply_of_players)
790 >>> winner.setLocation(None, None, 'America/Santiago', winner)
791 >>> loser.setLocation(None, None, 'America/New_York', loser)
792 >>> print decorator_refs(store, winner, loser)
793diff --git a/lib/lp/registry/doc/standing.txt b/lib/lp/registry/doc/standing.txt
794index 1678d43..fa3df52 100644
795--- a/lib/lp/registry/doc/standing.txt
796+++ b/lib/lp/registry/doc/standing.txt
797@@ -41,7 +41,7 @@ are not a member of, their message gets held for moderator approval.
798 ... Date: %s
799 ...
800 ... Point of order!
801- ... """ % (from_address, to_team_name, message_ids.next(), formatdate()))
802+ ... """ % (from_address, to_team_name, next(message_ids), formatdate()))
803 ... mailing_list = getUtility(IMailingListSet).get(to_team_name)
804 ... held_message = mailing_list.holdMessage(message)
805 ... return held_message
806diff --git a/lib/lp/registry/tests/test_milestonetag.py b/lib/lp/registry/tests/test_milestonetag.py
807index 93ab917..d3cad1e 100644
808--- a/lib/lp/registry/tests/test_milestonetag.py
809+++ b/lib/lp/registry/tests/test_milestonetag.py
810@@ -70,7 +70,7 @@ class MilestoneTagTest(TestCaseWithFactory):
811 MilestoneTag.created_by_id,
812 MilestoneTag.date_created,
813 )
814- created_by_id, date_created = values.next()
815+ created_by_id, date_created = next(values)
816 self.assertEqual(self.person.id, created_by_id)
817 self.assertIsInstance(date_created, datetime.datetime)
818
819diff --git a/lib/lp/services/apachelogparser/base.py b/lib/lp/services/apachelogparser/base.py
820index 8f3a438..f2e556a 100644
821--- a/lib/lp/services/apachelogparser/base.py
822+++ b/lib/lp/services/apachelogparser/base.py
823@@ -112,7 +112,7 @@ def parse_file(fd, start_position, logger, get_download_key, parsed_lines=0):
824 # logfile that has been rotated already, so it should be safe to
825 # parse its last line.
826 try:
827- next_line = fd.next()
828+ next_line = next(fd)
829 except StopIteration:
830 if parsed_lines > 0:
831 break
832diff --git a/lib/lp/services/doc/propertycache.txt b/lib/lp/services/doc/propertycache.txt
833index a4f2097..cd1fadf 100644
834--- a/lib/lp/services/doc/propertycache.txt
835+++ b/lib/lp/services/doc/propertycache.txt
836@@ -17,7 +17,7 @@ and then returned each time it is asked for.
837 >>> class Foo(object):
838 ... @cachedproperty
839 ... def bar(self):
840- ... return counter.next()
841+ ... return next(counter)
842
843 >>> foo = Foo()
844
845diff --git a/lib/lp/services/gpg/tests/test_gpghandler.py b/lib/lp/services/gpg/tests/test_gpghandler.py
846index ca24c3b..7007553 100644
847--- a/lib/lp/services/gpg/tests/test_gpghandler.py
848+++ b/lib/lp/services/gpg/tests/test_gpghandler.py
849@@ -144,7 +144,7 @@ class TestGPGHandler(TestCase):
850 def test_non_ascii_filter(self):
851 """localKeys should not error if passed non-ascii unicode strings."""
852 filtered_keys = self.gpg_handler.localKeys(u'non-ascii \u8463')
853- self.assertRaises(StopIteration, filtered_keys.next)
854+ self.assertRaises(StopIteration, next, filtered_keys)
855
856 def testTestkeyrings(self):
857 """Do we have the expected test keyring files"""
858diff --git a/lib/lp/services/librarianserver/swift.py b/lib/lp/services/librarianserver/swift.py
859index db01746..8f7f157 100644
860--- a/lib/lp/services/librarianserver/swift.py
861+++ b/lib/lp/services/librarianserver/swift.py
862@@ -309,7 +309,7 @@ class SwiftStream:
863
864 def _next_chunk(self):
865 try:
866- return self._chunks.next()
867+ return next(self._chunks)
868 except StopIteration:
869 return None
870
871diff --git a/lib/lp/services/mail/tests/mbox_mailer.txt b/lib/lp/services/mail/tests/mbox_mailer.txt
872index 0c67cfc..8e88bd2 100644
873--- a/lib/lp/services/mail/tests/mbox_mailer.txt
874+++ b/lib/lp/services/mail/tests/mbox_mailer.txt
875@@ -25,7 +25,7 @@ Read the mbox file and make sure the message we just mailed is in there.
876 >>> from mailbox import UnixMailbox
877 >>> mbox_file = open(mbox_filename)
878 >>> mbox = UnixMailbox(mbox_file)
879- >>> msg = mbox.next()
880+ >>> msg = next(mbox)
881 >>> msg['from']
882 'geddy@example.com'
883 >>> msg['to']
884@@ -43,7 +43,7 @@ Read the mbox file and make sure the message we just mailed is in there.
885
886 There should be no other messages in the mbox file.
887
888- >>> mbox.next()
889+ >>> next(mbox)
890 >>> mbox_file.close()
891
892 Create another mailer, again that overwrites. Make sure it actually does
893@@ -63,10 +63,10 @@ overwrite.
894
895 >>> mbox_file = open(mbox_filename)
896 >>> mbox = UnixMailbox(mbox_file)
897- >>> msg = mbox.next()
898+ >>> msg = next(mbox)
899 >>> msg['from']
900 'mick@example.com'
901- >>> mbox.next()
902+ >>> next(mbox)
903 >>> mbox_file.close()
904
905 Create another mailer, this time one that does not overwrite. Both the
906@@ -87,10 +87,10 @@ mbox file.
907
908 >>> mbox_file = open(mbox_filename)
909 >>> mbox = UnixMailbox(mbox_file)
910- >>> msg = mbox.next()
911+ >>> msg = next(mbox)
912 >>> msg['from']
913 'mick@example.com'
914- >>> msg = mbox.next()
915+ >>> msg = next(mbox)
916 >>> msg['from']
917 'carol@example.com'
918 >>> mbox_file.close()
919@@ -120,14 +120,14 @@ harness.
920
921 >>> mbox_file = open(mbox_filename)
922 >>> mbox = UnixMailbox(mbox_file)
923- >>> msg = mbox.next()
924+ >>> msg = next(mbox)
925 >>> msg['from']
926 'sting@example.com'
927- >>> msg = mbox.next()
928+ >>> msg = next(mbox)
929
930 >>> mbox_file = open(chained_filename)
931 >>> mbox = UnixMailbox(mbox_file)
932- >>> msg = mbox.next()
933+ >>> msg = next(mbox)
934 >>> msg['from']
935 'sting@example.com'
936- >>> msg = mbox.next()
937+ >>> msg = next(mbox)
938diff --git a/lib/lp/services/tests/test_utils.py b/lib/lp/services/tests/test_utils.py
939index dd50c8f..e753a82 100644
940--- a/lib/lp/services/tests/test_utils.py
941+++ b/lib/lp/services/tests/test_utils.py
942@@ -201,8 +201,8 @@ class TestCachingIterator(TestCase):
943 ci = CachingIterator(partial(iter, [0, 1, 2, 3, 4]))
944 i1 = iter(ci)
945 i2 = iter(ci)
946- self.assertEqual(0, i1.next())
947- self.assertEqual(0, i2.next())
948+ self.assertEqual(0, next(i1))
949+ self.assertEqual(0, next(i2))
950 self.assertEqual([1, 2, 3, 4], list(i2))
951 self.assertEqual([1, 2, 3, 4], list(i1))
952
953diff --git a/lib/lp/services/twistedsupport/tests/test_task.py b/lib/lp/services/twistedsupport/tests/test_task.py
954index 40abcc7..a40a31d 100644
955--- a/lib/lp/services/twistedsupport/tests/test_task.py
956+++ b/lib/lp/services/twistedsupport/tests/test_task.py
957@@ -4,6 +4,8 @@
958
959 __metaclass__ = type
960
961+from functools import partial
962+
963 from twisted.internet.defer import (
964 Deferred,
965 succeed,
966@@ -193,7 +195,8 @@ class TestPollingTaskSource(TestCase):
967 self.factory.getUniqueString(), self.factory.getUniqueString()]
968 consumer1_tasks = []
969 consumer2_tasks = []
970- task_source = self.makeTaskSource(task_producer=iter(tasks).next)
971+ task_source = self.makeTaskSource(
972+ task_producer=partial(next, iter(tasks)))
973 task_source.start(AppendingTaskConsumer(consumer1_tasks))
974 task_source.start(AppendingTaskConsumer(consumer2_tasks))
975 self.assertEqual(
976diff --git a/lib/lp/services/webapp/doc/canonical_url.txt b/lib/lp/services/webapp/doc/canonical_url.txt
977index 6d3c75a..8a52aa7 100644
978--- a/lib/lp/services/webapp/doc/canonical_url.txt
979+++ b/lib/lp/services/webapp/doc/canonical_url.txt
980@@ -333,19 +333,19 @@ We have to do the tests that involve errors bit by bit, to allow the doctest
981 to work properly.
982
983 >>> iterator = canonical_url_iterator(object_that_has_no_url)
984- >>> iterator.next().__class__.__name__
985+ >>> next(iterator).__class__.__name__
986 'object'
987- >>> iterator.next()
988+ >>> next(iterator)
989 Traceback (most recent call last):
990 ...
991 NoCanonicalUrl: No url for <...object...> because <...object...> broke the chain.
992
993 >>> iterator = canonical_url_iterator(unrooted_object)
994- >>> iterator.next().__class__.__name__
995+ >>> next(iterator).__class__.__name__
996 'ObjectThatHasUrl'
997- >>> iterator.next().__class__.__name__
998+ >>> next(iterator).__class__.__name__
999 'object'
1000- >>> iterator.next()
1001+ >>> next(iterator)
1002 Traceback (most recent call last):
1003 ...
1004 NoCanonicalUrl: No url for <...ObjectThatHasUrl...> because <...object...> broke the chain.
1005diff --git a/lib/lp/services/webapp/errorlog.py b/lib/lp/services/webapp/errorlog.py
1006index 2092e90..a64ce43 100644
1007--- a/lib/lp/services/webapp/errorlog.py
1008+++ b/lib/lp/services/webapp/errorlog.py
1009@@ -449,7 +449,7 @@ class ErrorReportingUtility:
1010 :param message: Unicode message.
1011 :returns: Key for this message.
1012 """
1013- key = self._oops_message_key_iter.next()
1014+ key = next(self._oops_message_key_iter)
1015 self._oops_messages[key] = message
1016 return key
1017
1018diff --git a/lib/lp/services/webapp/servers.py b/lib/lp/services/webapp/servers.py
1019index 33cf173..8b85df8 100644
1020--- a/lib/lp/services/webapp/servers.py
1021+++ b/lib/lp/services/webapp/servers.py
1022@@ -113,7 +113,7 @@ from lp.testopenid.interfaces.server import ITestOpenIDApplication
1023 from lp.xmlrpc.interfaces import IPrivateApplication
1024
1025
1026-class StepsToGo:
1027+class StepsToGo(six.Iterator):
1028 """
1029
1030 >>> class FakeRequest:
1031@@ -195,7 +195,7 @@ class StepsToGo:
1032 except IndexError:
1033 return None
1034
1035- def next(self):
1036+ def __next__(self):
1037 value = self.consume()
1038 if value is None:
1039 raise StopIteration
1040diff --git a/lib/lp/services/webapp/tests/test_authorization.py b/lib/lp/services/webapp/tests/test_authorization.py
1041index 5f5db72..8062473 100644
1042--- a/lib/lp/services/webapp/tests/test_authorization.py
1043+++ b/lib/lp/services/webapp/tests/test_authorization.py
1044@@ -489,7 +489,7 @@ class LoneObject(LaunchpadContainer):
1045
1046 def __init__(self):
1047 super(LoneObject, self).__init__(self)
1048- self.id = LoneObject._id_counter.next()
1049+ self.id = next(LoneObject._id_counter)
1050
1051 def getParentContainers(self):
1052 return []
1053diff --git a/lib/lp/testing/__init__.py b/lib/lp/testing/__init__.py
1054index 85ffd79..20a50d9 100644
1055--- a/lib/lp/testing/__init__.py
1056+++ b/lib/lp/testing/__init__.py
1057@@ -1320,11 +1320,11 @@ def time_counter(origin=None, delta=timedelta(seconds=5)):
1058 by the delta.
1059
1060 >>> now = time_counter(datetime(2007, 12, 1), timedelta(days=1))
1061- >>> now.next()
1062+ >>> next(now)
1063 datetime.datetime(2007, 12, 1, 0, 0)
1064- >>> now.next()
1065+ >>> next(now)
1066 datetime.datetime(2007, 12, 2, 0, 0)
1067- >>> now.next()
1068+ >>> next(now)
1069 datetime.datetime(2007, 12, 3, 0, 0)
1070 """
1071 if origin is None:
1072diff --git a/lib/lp/testing/factory.py b/lib/lp/testing/factory.py
1073index 6c0492f..61efb37 100644
1074--- a/lib/lp/testing/factory.py
1075+++ b/lib/lp/testing/factory.py
1076@@ -440,7 +440,7 @@ class ObjectFactory:
1077 For each thread, this will be a series of increasing numbers, but the
1078 starting point will be unique per thread.
1079 """
1080- return ObjectFactory._unique_int_counter.next()
1081+ return next(ObjectFactory._unique_int_counter)
1082
1083 def getUniqueHexString(self, digits=None):
1084 """Return a unique hexadecimal string.
1085@@ -1740,7 +1740,7 @@ class BareLaunchpadObjectFactory(ObjectFactory):
1086 revision = revision_set.new(
1087 revision_id=self.getUniqueString('revision-id'),
1088 log_body=self.getUniqueString('log-body'),
1089- revision_date=date_generator.next(),
1090+ revision_date=next(date_generator),
1091 revision_author=author,
1092 parent_ids=parent_ids,
1093 properties={})
1094@@ -2545,7 +2545,7 @@ class BareLaunchpadObjectFactory(ObjectFactory):
1095 # If a date_started is specified, then base the finish time
1096 # on that.
1097 if date_started is None:
1098- date_finished = time_counter().next()
1099+ date_finished = next(time_counter())
1100 else:
1101 date_finished = date_started + timedelta(hours=4)
1102 if date_started is None:
1103diff --git a/lib/lp/translations/browser/tests/test_translationmessage_view.py b/lib/lp/translations/browser/tests/test_translationmessage_view.py
1104index c196dc5..e7d7f88 100644
1105--- a/lib/lp/translations/browser/tests/test_translationmessage_view.py
1106+++ b/lib/lp/translations/browser/tests/test_translationmessage_view.py
1107@@ -9,6 +9,7 @@ from datetime import (
1108 datetime,
1109 timedelta,
1110 )
1111+from functools import partial
1112
1113 import pytz
1114 from zope.component import getUtility
1115@@ -58,7 +59,7 @@ class TestCurrentTranslationMessage_can_dismiss(TestCaseWithFactory):
1116 self.pofile = self.factory.makePOFile(potemplate=self.potemplate)
1117 self.potmsgset = self.factory.makePOTMsgSet(self.potemplate)
1118 self.view = None
1119- self.now = self._gen_now().next
1120+ self.now = partial(next, self._gen_now())
1121
1122 def _createView(self, message):
1123 self.view = CurrentTranslationMessageView(
1124diff --git a/lib/lp/translations/tests/test_potmsgset.py b/lib/lp/translations/tests/test_potmsgset.py
1125index c5aaae5..9ea5cc6 100644
1126--- a/lib/lp/translations/tests/test_potmsgset.py
1127+++ b/lib/lp/translations/tests/test_potmsgset.py
1128@@ -7,6 +7,7 @@ from datetime import (
1129 datetime,
1130 timedelta,
1131 )
1132+from functools import partial
1133
1134 import pytz
1135 import transaction
1136@@ -648,7 +649,7 @@ class TestPOTMsgSetSuggestions(TestCaseWithFactory):
1137 # Create a product with all the boilerplate objects to be able to
1138 # create TranslationMessage objects.
1139 super(TestPOTMsgSetSuggestions, self).setUp('carlos@canonical.com')
1140- self.now = self.gen_now().next
1141+ self.now = partial(next, self.gen_now())
1142 self.foo = self.factory.makeProduct(
1143 translations_usage=ServiceUsage.LAUNCHPAD)
1144 self.foo_main = self.factory.makeProductSeries(
1145@@ -846,7 +847,7 @@ class TestPOTMsgSetResetTranslation(TestCaseWithFactory):
1146 # create TranslationMessage objects.
1147 super(TestPOTMsgSetResetTranslation, self).setUp(
1148 'carlos@canonical.com')
1149- self.now = self.gen_now().next
1150+ self.now = partial(next, self.gen_now())
1151 self.foo = self.factory.makeProduct(
1152 translations_usage=ServiceUsage.LAUNCHPAD)
1153 self.foo_main = self.factory.makeProductSeries(

Subscribers

People subscribed via source and target branches

to status/vote changes: