Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#22107 closed Bug (fixed)

Iterating over File broken in Python 3

Reported by: Peter De Wachter Owned by: nobody
Component: Core (Other) Version: 1.6
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

django.core.files.File has an iterator to allow line-by-line access to the file. This does not work in Python 3 due to string/bytestring confusion. Attached patch fixes this and adds a regression test.

Attachments (1)

file-iteration.diff (989 bytes ) - added by Peter De Wachter 11 years ago.

Download all attachments as: .zip

Change History (5)

by Peter De Wachter, 11 years ago

Attachment: file-iteration.diff added

comment:1 by Baptiste Mispelon <bmispelon@…>, 11 years ago

Resolution: fixed
Status: newclosed

In 3841feee86cae65165f120db7a5d80ffc76dd520:

Fixed #22107 -- Fixed django.core.files.File object iteration.

Due to a mixup between text and bytes, iteration over
a File instance was broken under Python 3.

Thanks to trac user pdewacht for the report and patch.

comment:2 by Claude Paroz, 11 years ago

Triage Stage: UnreviewedAccepted

I think this would be a good candidate for backporting...

comment:3 by Baptiste Mispelon <bmispelon@…>, 11 years ago

In 12da6902e9cd8de2bc9eeef08c850a6c79aaa7cc:

[1.6.x] Fixed #22107 -- Fixed django.core.files.File object iteration.

Due to a mixup between text and bytes, iteration over
a File instance was broken under Python 3.

Thanks to trac user pdewacht for the report and patch.

Backport of 3841feee86cae65165f120db7a5d80ffc76dd520 from master.

in reply to:  2 comment:4 by Baptiste Mispelon, 11 years ago

Replying to claudep:

I think this would be a good candidate for backporting...

The problem has probably been here since 1.5 but I only backported to 1.6 because it's the first release that has full Python 3 support (1.5 had "experimental" support if I remember correctly).

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