Opened 20 months ago

Closed 20 months ago

Last modified 20 months ago

#21852 closed Bug (fixed)

Migration serializer cannot handle iterators

Reported by: MarkusH Owned by: MarkusH
Component: Migrations Version: master
Severity: Normal Keywords:
Cc: info@… Triage Stage: Ready for checkin
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

If the choices attribute of a model field is an iterable (not list, tuple, etc, but a e.g. a generator) the migration writer fails lacking a serialization path.

I suggest to serialize the iterable as a tuple.

Change History (6)

comment:1 Changed 20 months ago by MarkusH

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Status changed from new to assigned

comment:2 Changed 20 months ago by MarkusH

  • Summary changed from Migration serializer cannot handle iterables to Migration serializer cannot handle iterators

comment:3 Changed 20 months ago by bmispelon

  • Triage Stage changed from Unreviewed to Ready for checkin

I can reproduce the issue.

The proposed patch looks good: the added test fails with current master and passes after applying the patch.

I wonder however if collections.Iterator should be used instead of collections.Iterable, but that's just nitpicking.

I'll mark this as ready for checkin and try to get a second set of eyes to check it out before committing.

Thanks.

comment:4 Changed 20 months ago by MarkusH

Thanks bmispelon,

Looking at the collections documentation the table shows, that e.g. a Sequence is an Iterable but not an Iterator. That's why I'd stay with Iterable.

comment:5 Changed 20 months ago by Markus Holtermann <info@…>

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

In 047394f79c2cbc6cf44684a1f0d17aba1ddfe1c8:

Fixed #21852 -- Make migration writer serialize iterators

comment:6 Changed 20 months ago by Andrew Godwin <andrew@…>

In a5ec11c4bbb8f82e02871f154b3cfe0008b00a2b:

Merge pull request #2198 from Markush2010/ticket21852

Fixed #21852 -- Make migration writer serialize iterators

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