8000 Bug in cbook.exception_to_str() in v 1.2 by mdboom · Pull Request #2104 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Bug in cbook.exception_to_str() in v 1.2 #2104

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

Merged
merged 1 commit into from
Jun 3, 2013

Conversation

mdboom
Copy link
Member
@mdboom mdboom commented Jun 3, 2013

The exception_to_str() function was changed between mpl 1.1 and 1.2.
In my installation I show it going from this:

def exception_to_str(s = None):

sh = StringIO.StringIO()
if s is not None: print >>sh, s
traceback.print_exc(file=sh)
return sh.getvalue()

to this:

def exception_to_str(s=None):

sh = io.StringIO()
if s is not None:
    print(s, file=sh)
traceback.print_exc(file=sh)
return sh.getvalue()

At first glance, the change seems innocuous enough, but I think it
introduced an error. (It appears that mpl 1.2 is supposed to work on
Python 2.7 and 3.x.) From a thread I started on comp.lang.python
(http://thread.gmane.org/gmane.comp.python.general/733938), it appears
that io.StringIO instances only accept Unicode strings as input.
Unless v 1.2 is only supposed to run on Python 3 (that doesn't seem to
be the case), you need to do something to convert the traceback
module's output to Unicode before feeding to the io.StringIO object.

Here's a simple demonstration of the problem:

% python2.7
Python 2.7.5+ (2.7:93eb15779050, May 30 2013, 15:27:39)
[GCC 4.4.6 [TWW]] on linux2
Type "help", "copyright", "credits" or "license" for more information.

import traceback, StringIO, io
s1 = StringIO.StringIO()
traceback.print_stack(file=s1)
print repr(s1.getvalue())
' File "", line 1, in \n'

s2 = io.StringIO()
traceback.print_stack(file=s2)
Traceback (most recent call last):
File "", line 1, in
File "/home/skipm/x86_64-linux3.1/lib/python2.7/traceback.py", line
269, in print_stack
print_list(extract_stack(f, limit), file)
File "/home/skipm/x86_64-linux3.1/lib/python2.7/traceback.py", line
23, in print_list
' File "%s", line %d, in %s' % (filename,lineno,name))
File "/home/skipm/x86_64-linux3.1/lib/python2.7/traceback.py", line
13, in _print
file.write(str+terminator)
TypeError: unicode argument expected, got 'str'

@mdboom
Copy link
Member
mdboom commented Jun 3, 2013

@smontanaro: Can you confirm that the attached patch resolves your issue?

@smontanaro
Copy link
Author

I saw no patch, but applied the diff manually to my mpl 1.2 install and confirmed that it fixes the problem.

Will this go into 1.2 as well as 1.3?

@pelson
Copy link
Member
pelson commented Jun 3, 2013

👍

@mdboom
Copy link
Member
mdboom commented Jun 3, 2013

Yes. This will go in 1.2.x and 1.3.x (and master, for that matter).

8000

mdboom added a commit that referenced this pull request Jun 3, 2013
Bug in cbook.exception_to_str() in v 1.2
@mdboom mdboom merged commit 79d5905 into matplotlib:v1.2.x Jun 3, 2013
@megies
Copy link
Contributor
megies commented Aug 20, 2013

I just stumbled over this one. I applied the fix locally.. just curious (and thought I'd point this out just in case), are there any plans for a bugfix 1.2 release (since this is not in the latest 1.2 stable release 1.2.1)?

@WeatherGod
Copy link
Member

There has been discussions about doing 1.2.2. Perhaps we will do that as a
way to exercise some of the new automated build/testing work that will be
happening soon (MEP19). I know there are some bug fixes for mplot3d I have
been itching to take care of.

@pelson
Copy link
Member
pelson commented Aug 22, 2013

There has been discussions about doing 1.2.2.

That is a completely backwards step in my POV. We've just released v1.3.0 and should encourage anybody who asks to upgrade to that version (working with the latest release helps everybody, from the developers who try to support, to the users who discover and fix bugs in which have already been fixed in the latest release).

@efiring
Copy link
Member
efiring commented Aug 22, 2013

I agree with @pelson. Given our resource limitations, we need to minimize the number of active branches at any one time, so there would have to be a strong rationale for needing a 1.2.2.

@megies
Copy link
Contributor
megies commented Aug 22, 2013

I totally understand and can agree with focusing on 1.3. Just thought I'd mention it. Actually I had the 1.3 installed already but for some reason (I think some sphinx documentation not building) I went back to 1.2. Guess I'll just look into what was my problem with 1.3.

@mdboom mdboom deleted the exception_to_str branch August 7, 2014 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants
0