Opened 19 months ago

Closed 19 months ago

Last modified 19 months ago

#22107 closed Bug (fixed)

Iterating over File broken in Python 3

Reported by: pdewacht 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 pdewacht 19 months ago.

Download all attachments as: .zip

Change History (5)

Changed 19 months ago by pdewacht

comment:1 Changed 19 months ago by Baptiste Mispelon <bmispelon@…>

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

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 follow-up: Changed 19 months ago by claudep

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

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

comment:3 Changed 19 months ago by Baptiste Mispelon <bmispelon@…>

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.

comment:4 in reply to: ↑ 2 Changed 19 months ago by bmispelon

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