Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#20094 closed Bug (fixed)

Models with `next` method on python 2.6

Reported by: mjtamlyn Owned by: nobody
Component: Database layer (models, ORM) Version: 1.5
Severity: Normal Keywords:
Cc: claudep Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I've identified a problem with the following commit https://github.com/django/django/commit/df7a65ac4ba36dd155e80b8bcfe607390976ad47

The behaviour of isinstance(foo, collections.Iterable) is different between python 2.6 and python 2.7/3.X

This gist https://gist.github.com/mjtamlyn/5203598 will demonstrate the problem

The end result is that any model which defines a next method fails on python 2.6/django1.5 when used in a foreign key, as it has a next method but is not iterable.

Change History (4)

comment:1 Changed 2 years ago by claudep

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:3 Changed 2 years ago by Claude Paroz <claude@…>

  • Resolution set to fixed
  • Status changed from new to closed

In 829dc3c5a64d3fa203b8cc0055e83cf23addfee3:

Fixed #20094 - Be more careful when checking for Iterator

Python 2.6 has some different behaviour when checking
isinstance(foo, collections.Iterator).

comment:4 Changed 2 years ago by Claude Paroz <claude@…>

In dd897e4eeb20cab9ac708c46f34c5f09758205c8:

[1.5.x] Fixed #20094 - Be more careful when checking for Iterator

Python 2.6 has some different behaviour when checking
isinstance(foo, collections.Iterator).
Backport of 829dc3c5 from master.

Note: See TracTickets for help on using tickets.
Back to Top