Skip to content

[Bug]: for Python 3.11.9 got ValueError: PyCapsule_New called with null pointer #28267

Closed
@alekseiBochkarev

Description

@alekseiBochkarev

Bug summary

I got next error
src\tests\test_cover.py:48:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
src\tests\test_cover.py:202: in draw_diagram
fig, ax = plt.subplots(figsize=(14, 5), layout='constrained')
.venv\Lib\site-packages\matplotlib\pyplot.py:1702: in subplots
fig = figure(**fig_kw)
.venv\Lib\site-packages\matplotlib\pyplot.py:1022: in figure
manager = new_figure_manager(
.venv\Lib\site-packages\matplotlib\pyplot.py:545: in new_figure_manager
return _get_backend_mod().new_figure_manager(*args, **kwargs)
.venv\Lib\site-packages\matplotlib\backend_bases.py:3521: in new_figure_manager
return cls.new_figure_manager_given_figure(num, fig)
.venv\Lib\site-packages\matplotlib\backend_bases.py:3526: in new_figure_manager_given_figure
return cls.FigureCanvas.new_manager(figure, num)
.venv\Lib\site-packages\matplotlib\backend_bases.py:1811: in new_manager
return cls.manager_class.create_with_canvas(cls, figure, num)
.venv\Lib\site-packages\matplotlib\backends_backend_tk.py:479: in create_with_canvas
with _restore_foreground_window_at_end():
C:\Users\olapbuild\AppData\Local\Programs\Python\Python311\Lib\contextlib.py:137: in enter
return next(self.gen)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    @contextmanager
    def _restore_foreground_window_at_end():
>       foreground = _c_internal_utils.Win32_GetForegroundWindow()
E       ValueError: PyCapsule_New called with null pointer

.venv\Lib\site-packages\matplotlib\backends\_backend_tk.py:43: ValueError

Code for reproduction

def draw_diagram():
    width = 0.4  # Задаём ширину столбцов
    fig, ax = plt.subplots(figsize=(14, 5), layout='constrained')
    ax.bar(labels, cowered_data, width, label='Процент покрытых мер-измерений тестами')
    ax.bar(labels, uncowered_data, width, bottom=cowered_data,
           label='Процент непокрытых мер-измерений тестами')
    ax.set_ylabel('% покрытия')
    ax.set_title('Процент покрытия кубов тестами')
    ax.legend()
    plt.savefig('diagram.png')

Actual outcome

src\tests\test_cover.py:48:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
src\tests\test_cover.py:202: in draw_diagram
fig, ax = plt.subplots(figsize=(14, 5), layout='constrained')
.venv\Lib\site-packages\matplotlib\pyplot.py:1702: in subplots
fig = figure(**fig_kw)
.venv\Lib\site-packages\matplotlib\pyplot.py:1022: in figure
manager = new_figure_manager(
.venv\Lib\site-packages\matplotlib\pyplot.py:545: in new_figure_manager
return _get_backend_mod().new_figure_manager(*args, **kwargs)
.venv\Lib\site-packages\matplotlib\backend_bases.py:3521: in new_figure_manager
return cls.new_figure_manager_given_figure(num, fig)
.venv\Lib\site-packages\matplotlib\backend_bases.py:3526: in new_figure_manager_given_figure
return cls.FigureCanvas.new_manager(figure, num)
.venv\Lib\site-packages\matplotlib\backend_bases.py:1811: in new_manager
return cls.manager_class.create_with_canvas(cls, figure, num)
.venv\Lib\site-packages\matplotlib\backends_backend_tk.py:479: in create_with_canvas
with _restore_foreground_window_at_end():
C:\Users\olapbuild\AppData\Local\Programs\Python\Python311\Lib\contextlib.py:137: in enter
return next(self.gen)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    @contextmanager
    def _restore_foreground_window_at_end():
>       foreground = _c_internal_utils.Win32_GetForegroundWindow()
E       ValueError: PyCapsule_New called with null pointer

.venv\Lib\site-packages\matplotlib\backends\_backend_tk.py:43: ValueError

Expected outcome

diagram

Additional information

No response

Operating system

Windows NT

Matplotlib Version

3.9.0

Matplotlib Backend

tkagg

Python version

3.11.9, 3.12

Jupyter version

No response

Installation

pip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions