Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


bytes regex matching issue in around 1283 (line number) #1767

wants to merge 1 commit into from

5 participants

fedvasu Michael Droettboom Damon McDougall Thomas Spura Phil Elson

for match in _fc_match_regex.finditer(output):

the 'output' is a byte array, but expected is string runtime type-error,

i think this issue might already have been raised. I am using python3-mapltplotlib-tk backend on fedora 18. I am not sure if it is fixed or not.

THE FIX(atleast for me):
I change the above line to (I changed the byte array to utf-8 string)
for match in _fc_match_regex.finditer(output.decode("utf-8")):
and I am able to plot.No type-error

Michael Droettboom

I've attached an alternative fix that just changes the regex expression to be a byte string.

Damon McDougall

@fedvasu Does @mdboom's solution fix the problem?


@dmcdougall I will submit the patch link to fedora maintainers and we'll test there, I think, it should fix the issue.

Damon McDougall

@fedvasu Did you get any constructive feedback upstream regarding this? This is a simple change, but the Python 3 Travis build didn't complete. Can anyone confirm whether this is py3 safe?

Michael Droettboom

The Python 3 Travis build looks to be a false positive. This should be Python 3 safe (and works for me locally). subprocess.Popen returns bytes on both 2 and 3, so the regex over it should be bytes as well.

Thomas Spura

The alternative fix doesn't work for me, but the output decoding to utf-8 does.

That's because later on you check if the bytes extension is in the set of string extensions, which always fails. With the output decoding fix, both are always strings and that passes too.

I don't know, how to add a fix for this directly, so I sent another pull request in issue #1879.

Phil Elson

I'm closing this PR as it is a duplicate (in problem space, not in solution) to #1879. I'm not closing this PR because it is less good than #1879 - simply because only one PR is needed (whatever the solution).


Phil Elson pelson closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 20, 2013
  1. Michael Droettboom
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  lib/matplotlib/
2  lib/matplotlib/
@@ -1292,7 +1292,7 @@ def fc_match(pattern, fontext):
return file
return None
- _fc_match_regex = re.compile(r'\sfile:\s+"([^"]*)"')
+ _fc_match_regex = re.compile(br'\sfile:\s+"([^"]*)"')
_fc_match_cache = {}
def findfont(prop, fontext='ttf'):
Something went wrong with that request. Please try again.