Bug#1118347: scikit-learn: image tests fail treating text file as image

Drew Parsons dparsons at debian.org
Sat Oct 18 10:53:04 BST 2025


Source: scikit-learn
Version: 1.7.2+dfsg-2
Severity: serious
Justification: debci

scikit-learn 1.7.2+dfsg-2 is failing test_load_sample_image* from
test_base.py

It looks like it is cycling through all files in datasets/images
without discerning whether the file is an actual image file, so
failing when it processes README.txt.


926s ___________________________ test_load_sample_images ____________________________
926s 
926s     def test_load_sample_images():
926s         try:
926s >           res = load_sample_images()
926s                   ^^^^^^^^^^^^^^^^^^^^
926s 
926s /usr/lib/python3/dist-packages/sklearn/datasets/tests/test_base.py:230: 
926s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
926s /usr/lib/python3/dist-packages/sklearn/datasets/_base.py:1336: in load_sample_images
926s     descr = load_descr("README.txt", descr_module=IMAGES_MODULE)
926s             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
926s /usr/lib/python3/dist-packages/sklearn/datasets/_base.py:491: in load_descr
926s     return path.read_text(encoding=encoding)
926s            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
926s /usr/lib/python3.13/pathlib/_local.py:548: in read_text
926s     return PathBase.read_text(self, encoding, errors, newline)
926s            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
926s /usr/lib/python3.13/pathlib/_abc.py:632: in read_text
926s     with self.open(mode='r', encoding=encoding, errors=errors, newline=newline) as f:
926s          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
926s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
926s 
926s self = PosixPath('/usr/lib/python3/dist-packages/sklearn/datasets/images/README.txt')
926s mode = 'r', buffering = -1, encoding = 'utf-8', errors = None, newline = None
926s 
926s     def open(self, mode='r', buffering=-1, encoding=None,
926s              errors=None, newline=None):
926s         """
926s         Open the file pointed to by this path and return a file object, as
926s         the built-in open() function does.
926s         """
926s         if "b" not in mode:
926s             encoding = io.text_encoding(encoding)
926s >       return io.open(self, mode, buffering, encoding, errors, newline)
926s                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
926s E       FileNotFoundError: [Errno 2] No such file or directory: '/usr/lib/python3/dist-packages/sklearn/datasets/images/README.txt'
926s 
926s /usr/lib/python3.13/pathlib/_local.py:539: FileNotFoundError
926s ____________________________ test_load_sample_image ____________________________
926s 
926s     def test_load_sample_image():
926s         try:
926s >           china = load_sample_image("china.jpg")
926s                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
926s 
926s /usr/lib/python3/dist-packages/sklearn/datasets/tests/test_base.py:246: 
926s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
926s /usr/lib/python3/dist-packages/sklearn/utils/_param_validation.py:218: in wrapper
926s     return func(*args, **kwargs)
926s            ^^^^^^^^^^^^^^^^^^^^^
926s /usr/lib/python3/dist-packages/sklearn/datasets/_base.py:1392: in load_sample_image
926s     images = load_sample_images()
926s              ^^^^^^^^^^^^^^^^^^^^
926s /usr/lib/python3/dist-packages/sklearn/datasets/_base.py:1336: in load_sample_images
926s     descr = load_descr("README.txt", descr_module=IMAGES_MODULE)
926s             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
926s /usr/lib/python3/dist-packages/sklearn/datasets/_base.py:491: in load_descr
926s     return path.read_text(encoding=encoding)
926s            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
926s /usr/lib/python3.13/pathlib/_local.py:548: in read_text
926s     return PathBase.read_text(self, encoding, errors, newline)
926s            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
926s /usr/lib/python3.13/pathlib/_abc.py:632: in read_text
926s     with self.open(mode='r', encoding=encoding, errors=errors, newline=newline) as f:
926s          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
926s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
926s 
926s self = PosixPath('/usr/lib/python3/dist-packages/sklearn/datasets/images/README.txt')
926s mode = 'r', buffering = -1, encoding = 'utf-8', errors = None, newline = None
926s 
926s     def open(self, mode='r', buffering=-1, encoding=None,
926s              errors=None, newline=None):
926s         """
926s         Open the file pointed to by this path and return a file object, as
926s         the built-in open() function does.
926s         """
926s         if "b" not in mode:
926s             encoding = io.text_encoding(encoding)
926s >       return io.open(self, mode, buffering, encoding, errors, newline)
926s                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
926s E       FileNotFoundError: [Errno 2] No such file or directory: '/usr/lib/python3/dist-packages/sklearn/datasets/images/README.txt'
926s 
926s /usr/lib/python3.13/pathlib/_local.py:539: FileNotFoundError



More information about the debian-science-maintainers mailing list