Opened 3 years ago

Closed 3 years ago

#28384 closed defect (fixed)

py2: UnicodeDecodeError in doctest framework exception handling

Reported by: embray Owned by:
Priority: minor Milestone: sage-8.9
Component: doctest framework Keywords: unicode, locale
Cc: slelievre Merged in:
Authors: Erik Bray Reviewers: Samuel Lelièvre
Report Upstream: N/A Work issues:
Branch: 6c2f1e3 (Commits, GitHub, GitLab) Commit: 6c2f1e3e59ec5f4772a49310e5998a465c3fe94b
Dependencies: Stopgaps:

Status badges


I mentioned on #28116, that if an exception is raised in a doctest that happens to contain non-ASCII bytes in its message, there is a UnicodeDecodeError that occurs when trying to mix the text of the exception with unicode strings.

This can be reproduced by running:

LANG=fr_FR.UTF8 ./sage -bt src/sage/misc/

It happens to contain a test in which gcc is run, producing an error, which is wrapped in a RuntimeError. If the French localization of gcc is available then the error message contains unicode (in this case utf-8 encoded) characters that do not get decoded.

Change History (4)

comment:1 Changed 3 years ago by embray

  • Authors set to Erik Bray
  • Branch set to u/embray/ticket-28384
  • Commit set to 6c2f1e3e59ec5f4772a49310e5998a465c3fe94b
  • Status changed from new to needs_review

New commits:

6c2f1e3Trac #28384: Try to decode unicode text in tracebacks / exception messages in a couple more cases.

comment:2 Changed 3 years ago by embray

I thought of adding a regression test, but given that it's a huge pain to write one for the doctest framework, and that it's Python 2 only, I hope to get away without it.

comment:3 Changed 3 years ago by slelievre

  • Cc slelievre added
  • Keywords unicode locale added
  • Reviewers set to Samuel Lelièvre
  • Status changed from needs_review to positive_review

comment:4 Changed 3 years ago by vbraun

  • Branch changed from u/embray/ticket-28384 to 6c2f1e3e59ec5f4772a49310e5998a465c3fe94b
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.