Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG : fix str vs bytes issue in py3 in ps backend #3496

Merged
merged 1 commit into from Oct 4, 2014

Conversation

tacaswell
Copy link
Member

de-code the encoded ascii string so that it is a string, not
bytes, when it gets passed to the format function. Having the
b'' from the bytes string appear in the eps file breaks the file.

closes #3494

I really hope there is a better way to do this.

de-code the encoded ascii string so that it is a string, not
bytes, when it gets passed to the format function.  Having the
b'' from the bytes string appear in the eps file breaks the file.

closes matplotlib#3494
@tacaswell tacaswell added this to the v1.4.x milestone Sep 10, 2014
@mdboom
Copy link
Member

mdboom commented Sep 10, 2014

I don't know if there's a better way as long as Python3 is going to insist that:

('%s' % b'foo') == "b'foo'"

This seems like a fine solution.

@jkseppan
Copy link
Member

I agree, looks like a good solution.

One suggestion though: I think our test suite would have had a chance of catching this (assuming it exercises the ps backend) if the io.StringIO object here was replaced with six.StringIO. In Python 2, it's exactly the same, but in Python 3 it raises an exception if you try to output a byte string.

@mdboom
Copy link
Member

mdboom commented Sep 10, 2014

Unfortunately, we don't output the byte string directly, we do "%s" % byte_string on it, so even that wouldn't have caught it -- except running it through ghostscript would have presumably raised an error.

@jkseppan
Copy link
Member

Oh, right. It actually becomes a Unicode string representation of the bytestring syntax. That wouldn't have helped, then.

@tacaswell tacaswell modified the milestones: v1.4.1, v1.4.x Oct 4, 2014
@tacaswell
Copy link
Member Author

@matplotlib/developers Can this get reviewed? This should probably go in for the (now apparently delayed) 1.4.1.

efiring added a commit that referenced this pull request Oct 4, 2014
BUG : fix str vs bytes issue in py3 in ps backend
@efiring efiring merged commit 958c938 into matplotlib:v1.4.x Oct 4, 2014
@tacaswell tacaswell deleted the eps_fontname_bytes branch October 4, 2014 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants