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

Getdefaultencoding test error with sympy 0.7.1_git #2035

Closed
jenshnielsen opened this issue Jun 25, 2012 · 7 comments
Closed

Getdefaultencoding test error with sympy 0.7.1_git #2035

jenshnielsen opened this issue Jun 25, 2012 · 7 comments
Milestone

Comments

@jenshnielsen
Copy link
Contributor

I'm seeing the following test errors when a resent sympy git version is installed. Removing sympy from the system
solves the problem. I don't think it's an IPython bug but since it was quite hard to track down I will report it anyway.

======================================================================
ERROR: test suite for <module 'IPython.core.tests.test_compilerop' from '/usr/local/lib/python2.7/dist-packages/IPython/core/tests/test_compilerop.pyc'>
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/nose/suite.py", line 208, in run
    self.setUp()
  File "/usr/lib/python2.7/dist-packages/nose/suite.py", line 291, in setUp
    self.setupContext(ancestor)
  File "/usr/lib/python2.7/dist-packages/nose/suite.py", line 314, in setupContext
    try_run(context, names)
  File "/usr/lib/python2.7/dist-packages/nose/util.py", line 478, in try_run
    return func()
  File "/usr/local/lib/python2.7/dist-packages/IPython/core/tests/test_compilerop.py", line 55, in setUp
    nt.assert_equal(sys.getdefaultencoding(), "utf-8" if py3compat.PY3 else "ascii")
AssertionError: 'utf-8' != 'ascii'

======================================================================
ERROR: test suite for <module 'IPython.core.tests.test_history' from '/usr/local/lib/python2.7/dist-packages/IPython/core/tests/test_history.pyc'>
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/nose/suite.py", line 208, in run
    self.setUp()
  File "/usr/lib/python2.7/dist-packages/nose/suite.py", line 291, in setUp
    self.setupContext(ancestor)
  File "/usr/lib/python2.7/dist-packages/nose/suite.py", line 314, in setupContext
    try_run(context, names)
  File "/usr/lib/python2.7/dist-packages/nose/util.py", line 478, in try_run
    return func()
  File "/usr/local/lib/python2.7/dist-packages/IPython/core/tests/test_history.py", line 26, in setUp
    nt.assert_equal(sys.getdefaultencoding(), "utf-8" if py3compat.PY3 else "ascii")
AssertionError: 'utf-8' != 'ascii'

It appears that the import of sympy modifies the sys default encoding from ascii to utf-8.
This happens when the test suit is run as it checks for sympy in IPython.testing.decorators.

Steps to reproduce:
Install sympy master
sys.getdefaultencoding is ascii
import sympy
sys.getdefaultencoding is now utf-8

Note that this doesn't happen with sympy0.7.1 and also not with older dev. versions of sympy
(more than a few month I believe but I haven't bisected it. )

Observed on Ubuntu 12.04 with ipython 13 beta

@minrk
Copy link
Member

minrk commented Jun 25, 2012

Two things:

  • Changing this value is frowned upon with great vigor, and gtk gets lots of dirty looks for being the most prominent culprit.
  • I don't see this with current sympy master (aa989ce26e248d0f6b41c106271c9fdbc7af440e), so maybe it's actually sympy importing another package that is causing this. ack for defaultencoding turns up no results in sympy itself.

@jenshnielsen
Copy link
Contributor Author

Ok. I have bisected it to
https://github.com/sympy/sympy/tree/847bdfcb2c836d0e8853a9b985ef2bf88a925dd4

So it seems to be related to matplotlib. Removing matplotlib also removes the error
and indeed importing pyplot changes the value so sympy is not responsible in any way
it is just a result of sympy starting to use matplotlib to do plots. Note that just importing matplotlib does nothing
so thats the reason that check matplotlib does not trigger the error.

I'm running the latest version of matplotlib of the 1.1.1 branch and the same happens with
1.1.0. Clearing the .matlplotlib dir has no effect.

@minrk
Copy link
Member

minrk commented Jun 25, 2012

Is your default matplotlib backend gtk?

@jenshnielsen
Copy link
Contributor Author

Yes GTKAgg. And it doesn't happen with the qt4 and wx backends. So it seems to be GTK as
you suggested originally.

@minrk
Copy link
Member

minrk commented Jun 25, 2012

Okay, then I think we can close this, since A) it's not related to IPython, and B) gtk is known to mangle the Python runtime in unpleasant ways.

If we should do anything about it, it should be one or more of:

  • use skip instead of assert, so it doesn't look like IPython had a problem
  • clarify the message, explaining that your environment is borked so we don't want to run these tests

@jenshnielsen
Copy link
Contributor Author

Yes we can close it. I should add that the present combination of matplotlib backend and sympy also causes a
matplotlib user warning in the beginning of ipython core tests
since the matplotlib backend is set multiple times due to sympy setting it.

Same think happens if I import sympy and then activate pylab with the magic function in a regular ipython shell, but if anything this is a sympy issue and I will report it there.

@takluyver
Copy link
Member

The assert is fairly deliberate - I wanted it to highlight that there's something wrong with the test environment. I agree that we could clarify the message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants