Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#21852 closed Bug (fixed)

Migration serializer cannot handle iterators

Reported by: Markus Holtermann Owned by: Markus Holtermann
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


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 3 years ago by Markus Holtermann

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Status: newassigned

comment:2 Changed 3 years ago by Markus Holtermann

Summary: Migration serializer cannot handle iterablesMigration serializer cannot handle iterators

comment:3 Changed 3 years ago by Baptiste Mispelon

Triage Stage: UnreviewedReady 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.


comment:4 Changed 3 years ago by Markus Holtermann

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 3 years ago by Markus Holtermann <info@…>

Resolution: fixed
Status: assignedclosed

In 047394f79c2cbc6cf44684a1f0d17aba1ddfe1c8:

Fixed #21852 -- Make migration writer serialize iterators

comment:6 Changed 3 years 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