Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#23888 closed Bug (fixed)

UnicodeEncodeError on repr of File with unicode name

Reported by: Sergey Fedoseev Owned by: Sergey Fedoseev
Component: File uploads/storage Version: dev
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

Related to #8156.

In [1]: from django.core.files import File

In [2]: File(None, u'djángö')
Out[2]: <repr(<django.core.files.base.File at 0x7ff771a2ce90>) failed: UnicodeEncodeError: 'ascii' codec can't encode character u'\xe1' in position 9: ordinal not in range(128)>

Change History (6)

comment:1 by Baptiste Mispelon, 10 years ago

Triage Stage: UnreviewedAccepted

Hi,

Indeed, the repr appears to be broken.
Not sure what the best way to solve it is. Maybe using name.encode('raw_unicode_escape') on python 2?

Thanks.

comment:2 by Berker Peksag, 10 years ago

This commit seems to fix the problem: https://github.com/berkerpeksag/django/compare/23888 I'll add a release note and open a pull request.

in reply to:  2 comment:3 by Sergey Fedoseev, 10 years ago

Replying to berkerpeksag:

This commit seems to fix the problem: https://github.com/berkerpeksag/django/compare/23888 I'll add a release note and open a pull request.

Sorry, but I was first! =)
Already made a PR.

comment:4 by Baptiste Mispelon, 10 years ago

Has patch: set

PR at https://github.com/django/django/pull/3594 (make sure you include links to pull requests in tickets because some of us don't check both).

comment:5 by Tim Graham <timograham@…>, 10 years ago

Resolution: fixed
Status: newclosed

In 1e9ac504e46cae277398ee21038a08fffaafd060:

Fixed #23888 -- Fixed crash in File.repr() when name contains unicode.

comment:6 by Tim Graham <timograham@…>, 10 years ago

In 78fe7ec14ff14130a99edb30584b0ffc49c8ec8c:

[1.7.x] Fixed #23888 -- Fixed crash in File.repr() when name contains unicode.

Backport of 1e9ac504e4 from master

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