Opened 4 years ago

Closed 3 years ago

Last modified 3 years ago

#24379 closed defect (worksforme)

Matplotlib on Python 2 bugs out when there are non-ASCII characters in user's home directory

Reported by: embray Owned by:
Priority: major Milestone: sage-duplicate/invalid/wontfix
Component: packages: standard Keywords: matplotlib, days94
Cc: slelievre, epalezzato Merged in:
Authors: Reviewers: Erik Bray
Report Upstream: Fixed upstream, in a later stable release. Work issues:
Branch: Commit:
Dependencies: #25702 Stopgaps:

Status badges

Description (last modified by embray)

The matplotlib/__init__.py module contains from __future__ import unicode_literals which is often inadvisable, as it can run afoul of some of Python's own unicode bugs.

In particular at one point it calls os.path.expanduser('~'), where because of unicode_literals this becomes os.path.expanduser(u'~'). This does not take care to decode the results of os.environ['HOME'] (assuming it is ASCII), and ends up concatenating a unicode string with a non-unicode string, which means trying to first decoded the non-unicode string with the default (ASCII) encoding.

This is a bug in matplotlib but it affects Sage users, particularly on Windows where non-ASCII usernames are more common (may also affect OSX users): https://ask.sagemath.org/question/40131/sagemath-80-using-windows-installer

Upstream report: https://github.com/matplotlib/matplotlib/issues/10017

Change History (9)

comment:1 Changed 4 years ago by fbissey

It looks like it is still present in the latest release (2.1.0), for which I have been working on an upgrade at #23696.

from __future__ import (absolute_import, division, print_function,
                        unicode_literals)

comment:2 Changed 4 years ago by embray

  • Description modified (diff)
  • Report Upstream changed from Not yet reported upstream; Will do shortly. to Reported upstream. No feedback yet.

comment:3 Changed 4 years ago by embray

  • Milestone changed from sage-8.2 to sage-8.3

comment:4 Changed 4 years ago by epalezzato

  • Cc slelievre epalezzato added
  • Dependencies set to #25702
  • Keywords matplotlib days94 added
  • Report Upstream changed from Reported upstream. No feedback yet. to Fixed upstream, in a later stable release.

This should be solved by upgrading to matplotlib 2.2.2 which has the upstream fix.

comment:5 Changed 4 years ago by embray

  • Milestone changed from sage-8.3 to sage-8.4

comment:6 Changed 3 years ago by embray

  • Milestone changed from sage-8.4 to sage-8.5

comment:7 Changed 3 years ago by fbissey

  • Authors set to François Bissey
  • Milestone changed from sage-8.5 to sage-duplicate/invalid/wontfix
  • Status changed from new to needs_review

This is arguably fixed by #25702 (upgrade to MPL 2.2.2 with the fix).

comment:8 Changed 3 years ago by embray

  • Resolution set to worksforme
  • Status changed from needs_review to closed

Yep; IIRC this was fixed, thanks for the triaging.

comment:9 Changed 3 years ago by slelievre

  • Authors François Bissey deleted
  • Reviewers set to Erik Bray
Note: See TracTickets for help on using tickets.