Traceback to help fixing double-calls to mpl.use.#7303
Traceback to help fixing double-calls to mpl.use.#7303NelleV merged 1 commit intomatplotlib:masterfrom
Conversation
|
The doc failure looks un-related and due to merge conflicts. |
|
The message looks weird now. |
|
Just to clarify, another example:
|
|
I think this message will leave most users baffled. Filtering out all the importlib stuff might help. |
aab3ab3 to
f119e5f
Compare
|
Filtered out importlib line noise manually (possibly relevant python.org issues: http://bugs.python.org/issue15110, http://bugs.python.org/issue15386, http://bugs.python.org/issue15425). Now: We may also want to strip out the innermost frame but that may do more harm than good... |
|
Might want to update the commit message too, but it's not super important if nothing else requires any changes. |
Example session:
$ python -c 'import matplotlib as mpl; mpl.use("agg"); import matplotlib.pyplot; mpl.use("qt5agg")'
-c:1: UserWarning:
This call to matplotlib.use() has no effect because the backend has already
been chosen; matplotlib.use() must be called *before* pylab, matplotlib.pyplot,
or matplotlib.backends is imported for the first time.
The backend was *originally* set to 'agg' by the following code:
File "<string>", line 1, in <module>
File "/home/antony/src/extern/matplotlib/lib/matplotlib/pyplot.py", line 68, in <module>
from matplotlib.backends import pylab_setup
File "/home/antony/src/extern/matplotlib/lib/matplotlib/backends/__init__.py", line 14, in <module>
line for line in traceback.format_stack()
(In practice, you'd expect the two calls to be further apart from each
other, of course.)
Note that the *current* traceback can be accessed by standard means,
e.g. by setting the warnings filter.
Not sure how easy this is to test.
f119e5f to
8ce25d1
Compare
|
Good catch, fixed. |
|
Thanks @anntzer ! |
Example session:
(In practice, you'd expect the two calls to be further apart from each
other, of course.)
Note that the current traceback can be accessed by standard means,
e.g. by setting the warnings filter.
Not sure how easy this is to test.
See #7287.