Opened 6 years ago

Closed 6 years ago

Last modified 6 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: master
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 Changed 6 years ago by Baptiste Mispelon

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 Changed 6 years ago by Berker Peksag

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.

comment:3 in reply to:  2 Changed 6 years ago by Sergey Fedoseev

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 Changed 6 years ago by Baptiste Mispelon

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 Changed 6 years ago by Tim Graham <timograham@…>

Resolution: fixed
Status: newclosed

In 1e9ac504e46cae277398ee21038a08fffaafd060:

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

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

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