File tree 2 files changed +10
-36
lines changed 2 files changed +10
-36
lines changed Original file line number Diff line number Diff line change @@ -319,12 +319,9 @@ assert len(res.fetch(3)) == 1
319
319
assert len(res.fetch(3)) == 0
320
320
assert len(res.fetch(3)) == 0
321
321
try:
322
- # use next() or __next__(), the method name changed in
322
+ # use next() and not __next__(), the method name changed in
323
323
# http://www.python.org/dev/peps/pep-3114/
324
- try:
325
- res.next()
326
- except AttributeError:
327
- res.__next__()
324
+ next(res)
328
325
except StopIteration:
329
326
pass
330
327
else:
@@ -334,11 +331,7 @@ CREATE FUNCTION cursor_mix_next_and_fetch() RETURNS int AS $$
334
331
res = plpy.cursor("select fname, lname from users order by fname")
335
332
assert len(res.fetch(2)) == 2
336
333
337
- item = None
338
- try:
339
- item = res.next()
340
- except AttributeError:
341
- item = res.__next__()
334
+ item = next(res)
342
335
assert item['fname'] == 'rick'
343
336
344
337
assert len(res.fetch(2)) == 1
@@ -357,10 +350,7 @@ CREATE FUNCTION next_after_close() RETURNS int AS $$
357
350
res = plpy.cursor("select fname, lname from users")
358
351
res.close()
359
352
try:
360
- try:
361
- res.next()
362
- except AttributeError:
363
- res.__next__()
353
+ next(res)
364
354
except ValueError:
365
355
pass
366
356
else:
@@ -370,10 +360,7 @@ CREATE FUNCTION cursor_fetch_next_empty() RETURNS int AS $$
370
360
res = plpy.cursor("select fname, lname from users where false")
371
361
assert len(res.fetch(1)) == 0
372
362
try:
373
- try:
374
- res.next()
375
- except AttributeError:
376
- res.__next__()
363
+ next(res)
377
364
except StopIteration:
378
365
pass
379
366
else:
Original file line number Diff line number Diff line change @@ -218,12 +218,9 @@ assert len(res.fetch(3)) == 1
218
218
assert len(res .fetch (3 )) == 0
219
219
assert len(res .fetch (3 )) == 0
220
220
try:
221
- # use next() or __next__(), the method name changed in
221
+ # use next() and not __next__(), the method name changed in
222
222
# http://www.python.org/dev/peps/pep-3114/
223
- try:
224
- res .next ()
225
- except AttributeError:
226
- res .__next__ ()
223
+ next(res)
227
224
except StopIteration:
228
225
pass
229
226
else:
@@ -234,11 +231,7 @@ CREATE FUNCTION cursor_mix_next_and_fetch() RETURNS int AS $$
234
231
res = plpy .cursor (" select fname, lname from users order by fname" )
235
232
assert len(res .fetch (2 )) == 2
236
233
237
- item = None
238
- try:
239
- item = res .next ()
240
- except AttributeError:
241
- item = res .__next__ ()
234
+ item = next(res)
242
235
assert item[' fname' ] == ' rick'
243
236
244
237
assert len(res .fetch (2 )) == 1
@@ -259,10 +252,7 @@ CREATE FUNCTION next_after_close() RETURNS int AS $$
259
252
res = plpy .cursor (" select fname, lname from users" )
260
253
res .close ()
261
254
try:
262
- try:
263
- res .next ()
264
- except AttributeError:
265
- res .__next__ ()
255
+ next(res)
266
256
except ValueError:
267
257
pass
268
258
else:
@@ -273,10 +263,7 @@ CREATE FUNCTION cursor_fetch_next_empty() RETURNS int AS $$
273
263
res = plpy .cursor (" select fname, lname from users where false" )
274
264
assert len(res .fetch (1 )) == 0
275
265
try:
276
- try:
277
- res .next ()
278
- except AttributeError:
279
- res .__next__ ()
266
+ next(res)
280
267
except StopIteration:
281
268
pass
282
269
else:
You can’t perform that action at this time.
0 commit comments