commit:     0d0442b105ac58a68fc1ccf69b66f95725163ca0
Author:     Florian Schmaus <flow <AT> gentoo <DOT> org>
AuthorDate: Sun Nov  2 09:39:43 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon Nov  3 15:59:12 2025 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=0d0442b1

bintree: Restore "except OSError" block

With the refactoring done in Fixes: 16655f8588e3 ("bintree: fix
AttributeError by swapping try and for-loop"), two "except OSError"
blocks were merged into one. This restores the outer "except OSError"
block, because it used to catch the OSError that was re-raised deeper
inside the functions logic. Otherwise, the re-raised OSError would
cause Portage to abort, which was previously not the case.

Fixes: 16655f8588e3 ("bintree: fix AttributeError by swapping try and for-loop")
Closes: https://bugs.gentoo.org/965464
Signed-off-by: Florian Schmaus <flow <AT> gentoo.org>
Part-of: https://github.com/gentoo/portage/pull/1498
Signed-off-by: Sam James <sam <AT> gentoo.org>

 lib/portage/dbapi/bintree.py | 27 +++++++++++++--------------
 1 file changed, 13 insertions(+), 14 deletions(-)

diff --git a/lib/portage/dbapi/bintree.py b/lib/portage/dbapi/bintree.py
index ba3dc29999..47b46064dc 100644
--- a/lib/portage/dbapi/bintree.py
+++ b/lib/portage/dbapi/bintree.py
@@ -1529,20 +1529,6 @@ class binarytree:
                                 # not guaranteed to exist.
                                 continue
 
-                            # This includes URLError which is raised for SSL
-                            # certificate errors when PEP 476 is supported.
-                            writemsg(
-                                _(
-                                    "\n\n!!! [%s] Error fetching binhost 
package"
-                                    " info from '%s'\n"
-                                )
-                                % (binrepo_name, _hide_url_passwd(base_url))
-                            )
-                            error_msg = str(err)
-                            writemsg(f"!!!{binrepo_name} {error_msg}\n\n")
-                            del err
-                            pkgindex = None
-
                             if parsed_url.scheme in ("ftp", "http", "https"):
                                 # This protocol is supposedly supported by 
urlopen,
                                 # so apparently there's a problem with the url
@@ -1550,6 +1536,8 @@ class binarytree:
                                 if self.settings.get("PORTAGE_DEBUG", "0") != 
"0":
                                     traceback.print_exc()
 
+                                # Re-raise the OSError. It will be caught 
again in this function,
+                                # just above the remote_pkgindex_file loop.
                                 raise
                         except ValueError:
                             raise ParseError(
@@ -1699,6 +1687,17 @@ class binarytree:
                         _("[%s] Local copy of remote index is %s and will be 
used%s.\n")
                         % (binrepo_name, exc.desc, extra_info),
                     )
+            except OSError as err:
+                # This includes URLError which is raised for SSL
+                # certificate errors when PEP 476 is supported.
+                writemsg(
+                    _("\n\n!!! [%s] Error fetching binhost package" " info 
from '%s'\n")
+                    % (binrepo_name, _hide_url_passwd(base_url))
+                )
+                error_msg = str(err)
+                writemsg(f"!!!{binrepo_name} {error_msg}\n\n")
+                del err
+                pkgindex = None
 
             if pkgindex is rmt_idx and changed:
                 pkgindex.modified = False  # don't update the header

Reply via email to