#26147 closed defect (fixed)

py3: replace tests for attribute iteritems

Reported by: dkrenn Owned by:
Priority: major Milestone: sage-8.5
Component: python3 Keywords:
Cc: cheuberg Merged in:
Authors: Frédéric Chapoton Reviewers: Clemens Heuberger
Report Upstream: N/A Work issues:
Branch: 3220613 (Commits) Commit: 3220613358332abd7a2be92c1621ebc03b08dc7c
Dependencies: Stopgaps:

Description (last modified by cheuberg)

Replace hasattr( ..., 'iteritems') by hasattr( ..., 'items').

Change History (10)

comment:1 Changed 13 months ago by dkrenn

  • Branch set to u/dkrenn/py3-fsm

comment:2 Changed 13 months ago by dkrenn

  • Commit set to c5e75a00194e2759c8f227d1bad631fff55c3cab

...a first start.


New commits:

c5e75a0fix dicts and iter etc

comment:3 Changed 13 months ago by dkrenn

  • Cc cheuberg added

comment:4 Changed 13 months ago by cheuberg

I'd prefer to have a solution which solves this at a more global level, e.g. a function has_items() which performs this check and can be removed at the fullness of time when python2 support is dropped; similar in style to six. If these here are the only occurrences within all of sage, then this would of course be overkill.

comment:5 Changed 11 months ago by vklein

For the record #26468 and #26466 fix some py3 issues for FiniteStateMachines?.

comment:6 Changed 11 months ago by vklein

And note that mapping types also have an items methods in python2. I think if hasattr(data, 'iteritems') or hasattr(data, 'items'): can be simplified into if hasattr(data, 'items'):.

Last edited 11 months ago by vklein (previous) (diff)

comment:7 Changed 11 months ago by chapoton

  • Branch changed from u/dkrenn/py3-fsm to public/ticket/26147
  • Commit changed from c5e75a00194e2759c8f227d1bad631fff55c3cab to 3220613358332abd7a2be92c1621ebc03b08dc7c
  • Status changed from new to needs_review

here is the simplest way to go


New commits:

3220613no attribute 'iteritems' in python3

comment:8 Changed 11 months ago by cheuberg

  • Authors set to Frédéric Chapoton
  • Description modified (diff)
  • Reviewers set to Clemens Heuberger
  • Status changed from needs_review to positive_review
  • Summary changed from py3: doctests FiniteStateMachines to py3: replace tests for attribute iteritems

comment:9 Changed 11 months ago by chapoton

  • Milestone changed from sage-8.4 to sage-8.5

comment:10 Changed 11 months ago by vbraun

  • Branch changed from public/ticket/26147 to 3220613358332abd7a2be92c1621ebc03b08dc7c
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.