Issue 1:
Bug summary

Not sure if this is a Matplotlib bug or not. I am aware that this method is deprecated, but it is currently used in IPython and I assume that it shouldn't restart the terminal.

Executing the code in Spyder 5.2.1 with Python 3.9.7, IPython 7.30.1 and Matplotlib 3.5.1 a restart happens on my Windows 10 laptop. Same thing if executed in a standard python prompt (although only the deprecation warnings are shown).

On a Linux machine with Python 3.9.7 and IPython 7.29.0 it works (as in not crashing).

Code for reproduction

from io import BytesIO
from matplotlib import mathtext
mathtext.MathTextParser('bitmap').to_png(BytesIO(), '$x$')

Actual outcome

Python 3.9.7 | packaged by conda-forge | (default, Sep 29 2021, 19:15:42) [MSC v.1916 64 bit (AMD64)]
Type "copyright", "credits" or "license" for more information.

IPython 7.30.1 -- An enhanced Interactive Python.

from io import BytesIO

from matplotlib import mathtext

mathtext.MathTextParser('bitmap').to_png(BytesIO(), '$x$'

)
C:\Users\Oscar\AppData\Local\Temp/ipykernel_19884/2432144463.py:1: MatplotlibDeprecationWarning:
The to_png function was deprecated in Matplotlib 3.4 and will be removed two minor releases later. Use mathtext.math_to_image instead.
mathtext.MathTextParser('bitmap').to_png(BytesIO(), '$x$')
C:\Users\Oscar\AppData\Local\Temp/ipykernel_19884/2432144463.py:1: MatplotlibDeprecationWarning:
The to_rgba function was deprecated in Matplotlib 3.4 and will be removed two minor releases later. Use mathtext.math_to_image instead.
mathtext.MathTextParser('bitmap').to_png(BytesIO(), '$x$')
C:\Users\Oscar\AppData\Local\Temp/ipykernel_19884/2432144463.py:1: MatplotlibDeprecationWarning:
The to_mask function was deprecated in Matplotlib 3.4 and will be removed two minor releases later. Use mathtext.math_to_image instead.
mathtext.MathTextParser('bitmap').to_png(BytesIO(), '$x$')
C:\Users\Oscar\AppData\Local\Temp/ipykernel_19884/2432144463.py:1: MatplotlibDeprecationWarning:
The MathtextBackendBitmap class was deprecated in Matplotlib 3.4 and will be removed two minor releases later. Use mathtext.math_to_image instead.
mathtext.MathTextParser('bitmap').to_png(BytesIO(), '$x$')

Windows fatal exception: access violation

Main thread:
Current thread 0x00005478 (most recent call first):
File "C:\Users\Oscar\miniconda3\lib\site-packages\matplotlib\_mathtext.py", line 271 in _get_info
File "C:\Users\Oscar\miniconda3\lib\site-packages\matplotlib\_mathtext.py", line 150 in get_metrics
File "C:\Users\Oscar\miniconda3\lib\site-packages\matplotlib\_mathtext.py", line 1162 in _update_metrics
File "C:\Users\Oscar\miniconda3\lib\site-packages\matplotlib\_mathtext.py", line 1156 in __init__
File "C:\Users\Oscar\miniconda3\lib\site-packages\matplotlib\_mathtext.py", line 2356 in symbol
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 283 in wrapper
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 844 in _parseNoCache
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 907 in _parseCache
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 4074 in parseImpl
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 807 in _parseNoCache
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 907 in _parseCache
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 4335 in parseImpl
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 5186 in parseImpl
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 807 in _parseNoCache
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 907 in _parseCache
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 4919 in parseImpl
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 807 in _parseNoCache
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 907 in _parseCache
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 3828 in parseImpl
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 807 in _parseNoCache
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 907 in _parseCache
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 4074 in parseImpl
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 807 in _parseNoCache
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 907 in _parseCache
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 4335 in parseImpl
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 807 in _parseNoCache
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 907 in _parseCache
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 4335 in parseImpl
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 5186 in parseImpl
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 807 in _parseNoCache
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 907 in _parseCache
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 4074 in parseImpl
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 807 in _parseNoCache
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 907 in _parseCache
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 4335 in parseImpl
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 5186 in parseImpl
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 807 in _parseNoCache
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 907 in _parseCache
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 4074 in parseImpl
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 807 in _parseNoCache
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 907 in _parseCache
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 4335 in parseImpl
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 5186 in parseImpl
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 807 in _parseNoCache
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 907 in _parseCache
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 4750 in parseImpl
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 807 in _parseNoCache
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 907 in _parseCache
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 4335 in parseImpl
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 5186 in parseImpl
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 807 in _parseNoCache
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 907 in _parseCache
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 1117 in parse_string
File "C:\Users\Oscar\miniconda3\lib\site-packages\matplotlib\_mathtext.py", line 2300 in math_string
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 283 in wrapper
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 844 in _parseNoCache
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 907 in _parseCache
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 3828 in parseImpl
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 807 in _parseNoCache
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 907 in _parseCache
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 4750 in parseImpl
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 4851 in parseImpl
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 807 in _parseNoCache
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 907 in _parseCache
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 3850 in parseImpl
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 807 in _parseNoCache
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 907 in _parseCache
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 4335 in parseImpl
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 5186 in parseImpl
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 807 in _parseNoCache
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 907 in _parseCache
File "C:\Users\Oscar\miniconda3\lib\site-packages\pyparsing\core.py", line 1117 in parse_string
File "C:\Users\Oscar\miniconda3\lib\site-packages\matplotlib\_mathtext.py", line 2237 in parse
File "C:\Users\Oscar\miniconda3\lib\site-packages\matplotlib\mathtext.py", line 456 in _parse_cached
File "C:\Users\Oscar\miniconda3\lib\site-packages\matplotlib\mathtext.py", line 435 in parse
File "C:\Users\Oscar\miniconda3\lib\site-packages\matplotlib\mathtext.py", line 483 in to_mask
File "C:\Users\Oscar\miniconda3\lib\site-packages\matplotlib\_api\deprecation.py", line 205 in wrapper
File "C:\Users\Oscar\miniconda3\lib\site-packages\matplotlib\mathtext.py", line 509 in to_rgba
File "C:\Users\Oscar\miniconda3\lib\site-packages\matplotlib\_api\deprecation.py", line 205 in wrapper
File "C:\Users\Oscar\miniconda3\lib\site-packages\matplotlib\mathtext.py", line 542 in to_png
File "C:\Users\Oscar\miniconda3\lib\site-packages\matplotlib\_api\deprecation.py", line 205 in wrapper
File "C:\Users\Oscar\AppData\Local\Temp/ipykernel_19884/2432144463.py", line 1 in <module>

Restarting kernel...

Expected outcome

No restart.

Additional information

It worked "last time I tried" which was probably a year ago.

Operating system

Windows 10

Matplotlib Version

3.5.1

Matplotlib Backend

No response

Python version

No response

Jupyter version

No response

Installation

conda

Issue 2:
Bug summary

After updating matplotlib version 3.5.0 through conda update, there seem to be some issues using matplotlib in both Spyder and PyCharm, but they show different phenomena. I try to run a simple script using matplotlib (Please check the code in the Code for reproduction), what I see is described below:

In Spyder, the phenomena depend on the preferences (settings):

If the Inline Backend is used, the script can be run without any issues. But if the plt.show() is commented, I will not see the figure showing (Normally in Spyder, even without the code plt.show(), the figure should be shown.), and after a while, I see Restarting kernel... in the console.

If the Automatic Backend is used no matter the code plt.show() is commented or not, after the script is run, I can see the figure window popping up, but no figure is shown and the figure window is disappeared after one second around. After that, the Restarting kernel... is shown in the console.

In PyCharm:

After the script is run, again I can see the figure window popping up but no figure shown in the window. After around one second, the figure window disappears and the exit code is shown as Process finished with exit code -1073741819 (0xC0000005). If the code plt.show() is commented, the figure is not shown anymore which is normal while using PyCharm, and the exit code is shown as Process finished with exit code 0.

I consider there can be something wrong or bugs within the newest version of matplotlib, or maybe my setting issues. Could anyone help me with this issue?

Code for reproduction

import numpy as np
import matplotlib.pyplot as plt

x=np.arange(0,10)
y=np.arange(0,10)

plt.plot(x, y)
plt.show()

Actual outcome

Spyder:

Restarting kernel...

PyCharm:

Process finished with exit code -1073741819 (0xC0000005)

Expected outcome

A figure window with the expected figure shown on it

Additional information

No response

Operating system

Windows 10

Matplotlib Version

3.5.0

Matplotlib Backend

Qt5Agg

Python version

Python 3.8.12

Jupyter version

No response

Installation

conda