{"action":"created","issue":{"url":"https://api.github.com/repos/matplotlib/matplotlib/issues/12308","repository_url":"https://api.github.com/repos/matplotlib/matplotlib","labels_url":"https://api.github.com/repos/matplotlib/matplotlib/issues/12308/labels{/name}","comments_url":"https://api.github.com/repos/matplotlib/matplotlib/issues/12308/comments","events_url":"https://api.github.com/repos/matplotlib/matplotlib/issues/12308/events","html_url":"https://github.com/matplotlib/matplotlib/issues/12308","id":364536296,"node_id":"MDU6SXNzdWUzNjQ1MzYyOTY=","number":12308,"title":"#12253 FIX: Handle utf-8 output by kpathsea on Windows -- possibly causing issues","user":{"login":"pharshalp","id":15175620,"node_id":"MDQ6VXNlcjE1MTc1NjIw","avatar_url":"https://avatars3.githubusercontent.com/u/15175620?v=4","gravatar_id":"","url":"https://api.github.com/users/pharshalp","html_url":"https://github.com/pharshalp","followers_url":"https://api.github.com/users/pharshalp/followers","following_url":"https://api.github.com/users/pharshalp/following{/other_user}","gists_url":"https://api.github.com/users/pharshalp/gists{/gist_id}","starred_url":"https://api.github.com/users/pharshalp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pharshalp/subscriptions","organizations_url":"https://api.github.com/users/pharshalp/orgs","repos_url":"https://api.github.com/users/pharshalp/repos","events_url":"https://api.github.com/users/pharshalp/events{/privacy}","received_events_url":"https://api.github.com/users/pharshalp/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-09-27T15:37:54Z","updated_at":"2018-10-01T09:42:49Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"<!--To help us understand and resolve your issue, please fill out the form to the best of your ability.-->\r\n<!--You can feel free to delete the sections that do not apply.-->\r\n\r\n### Bug report\r\nI like to test my code against the bleeding edge version of matplotlib (by installing it in a conda virtual environment) on my work machine (Windows PC). Since I do not have admin rights to install the necessary tools to build from source, I download the wheels from appveyor and use pip install.\r\n\r\nThe following code snippet (representing a part of my working code) started giving an error after I installed \"matplotlib-3.0.0rc1+424.g19420b97.dirty-cp36-cp36m-win_amd64.whl\" (which corresponds to Merge pull request #12253 from anntzer/kpathsea-encoding FIX: Handle utf-8 output by kpathsea on Windows). The wheel which was built for the commit before that, matplotlib-3.0.0rc1+420.gb2c89917.dirty-cp36-cp36m-win_amd64.whl works fine (I reinstalled it and the code snippet works).\r\n\r\nI am not sure if this is the right way to test the bleeding edge code (when you do not have admin rights to install the tools necessary to build from source). If the procedure I am following is not correct, please feel free to close the issue.\r\n<!--A short 1-2 sentences that succinctly describes the bug-->\r\n\r\n**Code for reproduction**\r\n```python\r\nimport matplotlib.pyplot as plt\r\nimport numpy as np\r\nfrom matplotlib import rc\r\nrc('text', usetex=True)\r\nrc('text.latex', preamble=r'\\usepackage{fourier}, \\usepackage[T1]{fontenc}')\r\nfig, ax = plt.subplots()\r\nax.plot(np.arange(10))\r\nfig.savefig('test.pdf')\r\n```\r\n<!--A minimum code snippet required to reproduce the bug, also minimizing the number of dependencies required-->\r\n\r\n**Actual outcome**\r\n\r\n<!--The output produced by the above code, which may be a screenshot, console output, etc.-->\r\n\r\n```\r\nOSError: [Errno 22] Invalid argument: 'C:/Program Files/MiKTeX 2.9/fonts/tfm/jknappen/ec/ecss1000.tfm\r\n\\r'\r\n```\r\n\r\n**Expected outcome**\r\n\r\n<!--A description of the expected outcome from the code snippet-->\r\n<!--If this used to work in an earlier version of Matplotlib, please note the version it used to work on-->\r\n\r\n**Matplotlib version**\r\n<!--Please specify your platform and versions of the relevant libraries you are using:-->\r\n  * Operating system: Windows 10\r\n  * Matplotlib version: 3.0.0rc1+424.g19420b97.dirty\r\n  * Matplotlib backend (`print(matplotlib.get_backend())`): Qt5Agg\r\n\r\n  * Python version:\r\n  * Jupyter version (if applicable):\r\n  * Other libraries: \r\n\r\n<!--Please tell us how you installed matplotlib and python e.g., from source, pip, conda-->\r\n<!--If you installed from conda, please specify which channel you used if not the default-->\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/matplotlib/matplotlib/issues/comments/425848061","html_url":"https://github.com/matplotlib/matplotlib/issues/12308#issuecomment-425848061","issue_url":"https://api.github.com/repos/matplotlib/matplotlib/issues/12308","id":425848061,"node_id":"MDEyOklzc3VlQ29tbWVudDQyNTg0ODA2MQ==","user":{"login":"anntzer","id":1322974,"node_id":"MDQ6VXNlcjEzMjI5NzQ=","avatar_url":"https://avatars0.githubusercontent.com/u/1322974?v=4","gravatar_id":"","url":"https://api.github.com/users/anntzer","html_url":"https://github.com/anntzer","followers_url":"https://api.github.com/users/anntzer/followers","following_url":"https://api.github.com/users/anntzer/following{/other_user}","gists_url":"https://api.github.com/users/anntzer/gists{/gist_id}","starred_url":"https://api.github.com/users/anntzer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anntzer/subscriptions","organizations_url":"https://api.github.com/users/anntzer/orgs","repos_url":"https://api.github.com/users/anntzer/repos","events_url":"https://api.github.com/users/anntzer/events{/privacy}","received_events_url":"https://api.github.com/users/anntzer/received_events","type":"User","site_admin":false},"created_at":"2018-10-01T09:42:49Z","updated_at":"2018-10-01T09:42:49Z","author_association":"CONTRIBUTOR","body":"Sorry about that.  I think the following patch should suffice, can you confirm it?\r\n```\r\ndiff --git i/lib/matplotlib/dviread.py w/lib/matplotlib/dviread.py\r\nindex f064113ad..a47320176 100644\r\n--- i/lib/matplotlib/dviread.py\r\n+++ w/lib/matplotlib/dviread.py\r\n@@ -1017,16 +1017,16 @@ def find_tex_file(filename, format=None):\r\n     if format is not None:\r\n         cmd += ['--format=' + format]\r\n     cmd += [filename]\r\n-    try:  # Below: strip final newline.\r\n-        result = cbook._check_and_log_subprocess(cmd, _log)[:-1]\r\n+    try:\r\n+        result = cbook._check_and_log_subprocess(cmd, _log)\r\n     except RuntimeError:\r\n         return ''\r\n     if os.name == 'nt':\r\n         # On Windows only, kpathsea appears to use utf-8 output(?); see\r\n         # __win32_fputs in the kpathsea sources and mpl issue #11848.\r\n-        return result.decode('utf-8')\r\n+        return result.decode('utf-8')[:-2]  # Strip final '\\r\\n'.\r\n     else:\r\n-        return os.fsdecode(result)\r\n+        return os.fsdecode(result)[:-1]  # Strip final '\\n'.\r\n \r\n \r\n @lru_cache()\r\n```\r\n\r\nWe should really reenable tex testing on appveyor..."}}
{"actor":{"display_login":"anntzer"}}