Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Bug]: Settingtext.usetex=True inpyplot.rcParams Raises FIPS Compliance Errors #29603

Milestone
@martinky24

Description

@martinky24

Bug summary

If you use a FIPS (Federal Information Processing Standards) compliant Python install, then you cannot usepyplot.show to display a plot withplt.rcParams['text.usetex'] = True due to ahashlib.md5 call intexmanager.py.

This is similar to#18192 (and much of this report is modeled off of that)

There are 3 places in the code that seem to still usehashlib.md5:

There probably isn't a great reason not to replace md5 with sha256 (or something else) in these locations.

Code for reproduction

The big requirement here is a FIPS compliant system or at least a Python install compiled to be FIPS compliant. Then the following code will reproduce the error.

To reproduce,

  1. Runsudo fips-mode-setup --enable && sudo reboot (there may be other methods)
  2. After the reboot I confirmed FIPS mode had been enabled by runningfips-mode-setup --check and it returned FIPS mode is enabled.
  3. python3 -m venv .venv
  4. ./.venv/bin/python -m pip install matplotlib==3.10.0
  5. ./.venv/bin/python fips_error.py. The contents offips_error.py is listed below.
importmatplotlib.pyplotaspltplt.rcParams['text.usetex']=Truefig,ax=plt.subplots()plt.text(0,0,r'$\hat{\mathbf{x}}$')plt.show()

Actual outcome

$ python fips_error.py Exception in Tkinter callbackTraceback (most recent call last):  File "/usr/lib64/python3.11/tkinter/__init__.py", line 1967, in __call__    return self.func(*args)           ^^^^^^^^^^^^^^^^  File "/usr/lib64/python3.11/tkinter/__init__.py", line 861, in callit    func(*args)  File "/data/users/ktm/matplotlib_test/.venv/lib64/python3.11/site-packages/matplotlib/backends/_backend_tk.py", line 274, in idle_draw    self.draw()  File "/data/users/ktm/matplotlib_test/.venv/lib64/python3.11/site-packages/matplotlib/backends/backend_tkagg.py", line 10, in draw    super().draw()  File "/data/users/ktm/matplotlib_test/.venv/lib64/python3.11/site-packages/matplotlib/backends/backend_agg.py", line 382, in draw    self.figure.draw(self.renderer)  File "/data/users/ktm/matplotlib_test/.venv/lib64/python3.11/site-packages/matplotlib/artist.py", line 94, in draw_wrapper    result = draw(artist, renderer, *args, **kwargs)             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "/data/users/ktm/matplotlib_test/.venv/lib64/python3.11/site-packages/matplotlib/artist.py", line 71, in draw_wrapper    return draw(artist, renderer)           ^^^^^^^^^^^^^^^^^^^^^^  File "/data/users/ktm/matplotlib_test/.venv/lib64/python3.11/site-packages/matplotlib/figure.py", line 3257, in draw    mimage._draw_list_compositing_images(  File "/data/users/ktm/matplotlib_test/.venv/lib64/python3.11/site-packages/matplotlib/image.py", line 134, in _draw_list_compositing_images    a.draw(renderer)  File "/data/users/ktm/matplotlib_test/.venv/lib64/python3.11/site-packages/matplotlib/artist.py", line 71, in draw_wrapper    return draw(artist, renderer)           ^^^^^^^^^^^^^^^^^^^^^^  File "/data/users/ktm/matplotlib_test/.venv/lib64/python3.11/site-packages/matplotlib/axes/_base.py", line 3181, in draw    mimage._draw_list_compositing_images(  File "/data/users/ktm/matplotlib_test/.venv/lib64/python3.11/site-packages/matplotlib/image.py", line 134, in _draw_list_compositing_images    a.draw(renderer)  File "/data/users/ktm/matplotlib_test/.venv/lib64/python3.11/site-packages/matplotlib/artist.py", line 71, in draw_wrapper    return draw(artist, renderer)           ^^^^^^^^^^^^^^^^^^^^^^  File "/data/users/ktm/matplotlib_test/.venv/lib64/python3.11/site-packages/matplotlib/axis.py", line 1416, in draw    tlb1, tlb2 = self._get_ticklabel_bboxes(ticks_to_draw, renderer)                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "/data/users/ktm/matplotlib_test/.venv/lib64/python3.11/site-packages/matplotlib/axis.py", line 1343, in _get_ticklabel_bboxes    return ([tick.label1.get_window_extent(renderer)            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "/data/users/ktm/matplotlib_test/.venv/lib64/python3.11/site-packages/matplotlib/axis.py", line 1343, in <listcomp>    return ([tick.label1.get_window_extent(renderer)             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "/data/users/ktm/matplotlib_test/.venv/lib64/python3.11/site-packages/matplotlib/text.py", line 969, in get_window_extent    bbox, info, descent = self._get_layout(self._renderer)                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "/data/users/ktm/matplotlib_test/.venv/lib64/python3.11/site-packages/matplotlib/text.py", line 373, in _get_layout    _, lp_h, lp_d = _get_text_metrics_with_cache(                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "/data/users/ktm/matplotlib_test/.venv/lib64/python3.11/site-packages/matplotlib/text.py", line 69, in _get_text_metrics_with_cache    return _get_text_metrics_with_cache_impl(           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "/data/users/ktm/matplotlib_test/.venv/lib64/python3.11/site-packages/matplotlib/text.py", line 77, in _get_text_metrics_with_cache_impl    return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "/data/users/ktm/matplotlib_test/.venv/lib64/python3.11/site-packages/matplotlib/backends/backend_agg.py", line 211, in get_text_width_height_descent    return super().get_text_width_height_descent(s, prop, ismath)           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "/data/users/ktm/matplotlib_test/.venv/lib64/python3.11/site-packages/matplotlib/backend_bases.py", line 566, in get_text_width_height_descent    return self.get_texmanager().get_text_width_height_descent(           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "/data/users/ktm/matplotlib_test/.venv/lib64/python3.11/site-packages/matplotlib/texmanager.py", line 360, in get_text_width_height_descent    dvifile = cls.make_dvi(tex, fontsize)              ^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "/data/users/ktm/matplotlib_test/.venv/lib64/python3.11/site-packages/matplotlib/texmanager.py", line 276, in make_dvi    basefile = cls.get_basefile(tex, fontsize)               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "/data/users/ktm/matplotlib_test/.venv/lib64/python3.11/site-packages/matplotlib/texmanager.py", line 171, in get_basefile    filehash = hashlib.md5(src.encode('utf-8')).hexdigest()               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ValueError: [digital envelope routines: EVP_DigestInit_ex] disabled for FIPS

Expected outcome

No exception related to FIPS and the plot is created.

Additional information

$ .venv/bin/python -m pip listPackage         Version--------------- -----------contourpy       1.3.1cycler          0.12.1fonttools       4.56.0kiwisolver      1.4.8matplotlib      3.10.0numpy           2.2.2packaging       24.2pillow          11.1.0pip             22.3.1pyparsing       3.2.1python-dateutil 2.9.0.post0setuptools      65.5.1six             1.17.0

Operating system

RHEL 8.10 (with FIPS enabled)

Matplotlib Version

3.10.0

Matplotlib Backend

tkagg

Python version

Python 3.11.9

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


      [8]ページ先頭

      ©2009-2025 Movatter.jp