Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#20354 closed Bug (fixed)

`makemessages` crashes when reading non-UTF8 encoded files.

Reported by: mrmachine Owned by: nobody
Component: Core (Management commands) Version: master
Severity: Release blocker 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

I have a project with a 3rd party bundled file (MIT-license.txt) which is apparently not encoded with UTF-8 and contains some characters that makes the makemessages management command crash with a UnicodeDecodeError. It outputs the full contents of the file, but not the file name or location. Not very helpful.

I don't really want to have to search my project for 3rd party non-UTF8 files with a .txt or .html extension and convert them to UTF8. I'd rather leave 3rd party files as they are so I can diff and update them easier.

I also don't really want to do a find across the whole project looking for a match against the content that caused the error, so I can work out the filename and explicitly ignore it with a glob pattern.

I'd like Django to simply warn me that the file generated a UnicodeDecodeError and was skipped, then continue processing other files. If it's important, then I can go and fix it.

Change History (4)

comment:1 Changed 2 years ago by mrmachine

  • Has patch set
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 2 years ago by claudep

  • Severity changed from Normal to Release blocker
  • Triage Stage changed from Unreviewed to Accepted

It might be a regression in 1.5.

comment:3 Changed 2 years ago by Claude Paroz <claude@…>

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

In 99a6f0e77c6e02b310687667d41df56c17b953bf:

Fixed #20354 -- makemessages no longer crashes with UnicodeDecodeError

Handle the UnicodeDecodeError exception, send a warning to stdout with the
file name and location, and continue processing other files.

comment:4 Changed 2 years ago by Claude Paroz <claude@…>

In 23b234a9d9ea26acb9bb12ba14231ce8844d2e53:

[1.5.x] Fixed #20354 -- makemessages no longer crashes with UnicodeDecodeError

Handle the UnicodeDecodeError exception, send a warning to stdout with the
file name and location, and continue processing other files.
Backport of 99a6f0e77 from master.

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