Thanks to visit codestin.com
Credit goes to github.com

Skip to content

recursive import : bug in cbook.unicode_safe #593

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
Nov 28, 2011

Conversation

mdboom
Copy link
Member

@mdboom mdboom commented Nov 17, 2011

I find the following recursive import :
matplotlib.init --> matplotlib.rcsetup --> matplotlib.colors --> matplotlib.cbook --> matplotlib.init
with :
- matplotlib.rcsetup imported line 133
- matplotlib.rcParams defined much later
- and cbook asking for rcParams["axes.formatter.use_local"]

@mdboom
Copy link
Member

mdboom commented Nov 16, 2011

What version of matplotlib are you referring to? master has a similar cycle, but it isn't problematic (and the line number you refer to doesn't match). Can you attach a traceback if you are getting one?

@poldavezac
Copy link
Author

I'm using 1.1, downloaded a few days ago
there is no traceback to speak of as the call to rcParams is encapsulated
in a try/except clause.

I've commented that clause to obtain as follows

c:\code\trunk\OPL\opl\test>plottemporal.py
Traceback (most recent call last):
File "C:\code\trunk\OPL\opl\test\plottemporal.py", line 11, in
from opl.test.plot import iTestPlot, iTestShownDrawBase, testPlotFactory
File "c:\code\trunk\OPL\opl\test\plot.py", line 4, in
from opl.draw.canvas import SimpleCanvas
File "c:\code\trunk\OPL\opl\draw__init__.py", line 139, in
import matplotlib.cbook as cbook
File
"C:\code\environment\python\v27\lib\site-packages\matplotlib__init__.py",
line 133, in
from matplotlib.rcsetup import (defaultParams,
File
"C:\code\environment\python\v27\lib\site-packages\matplotlib\rcsetup.py",
line 19, in
from matplotlib.colors import is_color_like
File
"C:\code\environment\python\v27\lib\site-packages\matplotlib\colors.py",
line 54, in
import matplotlib.cbook as cbook
File
"C:\code\environment\python\v27\lib\site-packages\matplotlib\cbook.py",
line 34, in
matplotlib.rcParams['axes.formatter.use_locale']).strip()
AttributeError: 'module' object has no attribute 'rcParams'

On Wed, Nov 16, 2011 at 8:25 PM, Michael Droettboom <
[email protected]

wrote:

What version of matplotlib are you referring to? master has a similar
cycle, but it isn't problematic (and the line number you refer to doesn't
match). Can you attach a traceback if you are getting one?


Reply to this email directly or view it on GitHub:
#593 (comment)

@poldavezac
Copy link
Author

My apologies, I realize I read your mail too quickly:
You say the cycle is not a problem. I believe it is, although a try
except clause does hide this.

The bug is that matplotlib.rcParams raises an AttributeError. The exception
is caught but the result is that the module variable "preferedencoding" is
not initialized correctly. In turn, this later results in UnicodeError
when, for exemple, one tries to plot dates.

Regards,

On Wed, Nov 16, 2011 at 10:01 PM, Pol d'Avezac [email protected]:

I'm using 1.1, downloaded a few days ago
there is no traceback to speak of as the call to rcParams is encapsulated
in a try/except clause.

I've commented that clause to obtain as follows

c:\code\trunk\OPL\opl\test>plottemporal.py
Traceback (most recent call last):
File "C:\code\trunk\OPL\opl\test\plottemporal.py", line 11, in
from opl.test.plot import iTestPlot, iTestShownDrawBase, testPlotFactory
File "c:\code\trunk\OPL\opl\test\plot.py", line 4, in
from opl.draw.canvas import SimpleCanvas
File "c:\code\trunk\OPL\opl\draw__init__.py", line 139, in
import matplotlib.cbook as cbook
File
"C:\code\environment\python\v27\lib\site-packages\matplotlib__init__.py",
line 133, in
from matplotlib.rcsetup import (defaultParams,
File
"C:\code\environment\python\v27\lib\site-packages\matplotlib\rcsetup.py",
line 19, in
from matplotlib.colors import is_color_like
File
"C:\code\environment\python\v27\lib\site-packages\matplotlib\colors.py",
line 54, in
import matplotlib.cbook as cbook
File
"C:\code\environment\python\v27\lib\site-packages\matplotlib\cbook.py",
line 34, in
matplotlib.rcParams['axes.formatter.use_locale']).strip()
AttributeError: 'module' object has no attribute 'rcParams'

On Wed, Nov 16, 2011 at 8:25 PM, Michael Droettboom <
[email protected]

wrote:

What version of matplotlib are you referring to? master has a similar
cycle, but it isn't problematic (and the line number you refer to doesn't
match). Can you attach a traceback if you are getting one?


Reply to this email directly or view it on GitHub:
#593 (comment)

@mdboom
Copy link
Member

mdboom commented Nov 17, 2011

Thanks for clarifying. I'll have a fix for this shortly.

@mdboom
Copy link
Member

mdboom commented Nov 17, 2011

@poldavezac: When you get a chance, can you confirm this patch fixes the issue for you?

@poldavezac
Copy link
Author

Yes it works

Thanks,

On Thu, Nov 17, 2011 at 5:46 PM, Michael Droettboom <
[email protected]

wrote:

@poldavezac: When you get a chance, can you confirm this patch fixes the
issue for you?


Reply to this email directly or view it on GitHub:
#593 (comment)

mdboom added a commit that referenced this pull request Nov 28, 2011
recursive import : bug in cbook.unicode_safe
@mdboom mdboom merged commit 62073cf into matplotlib:v1.1.x Nov 28, 2011
@leejjoon
Copy link
Contributor

@mdboom: can you merge it into the master branch? currently it gives a merge conflict.

@mdboom
Copy link
Member

mdboom commented Nov 28, 2011

@leejjoon: Done

@mdboom mdboom deleted the recursive_import branch March 3, 2015 18:44
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.

3 participants