From 71a8580e7f6beb4311b3f2555cf9557c2e39b22a Mon Sep 17 00:00:00 2001 From: Nikita Gerasimov Date: Sat, 9 Mar 2024 20:20:15 +0300 Subject: [PATCH] Rewrites "original_name" method to check if "cls" has a "backmap" In some cases, such as fail of "mock --chain --recurse some.src.rpm.tofail", FileDownloader "cls" may not have a "backmap" attribute. So we have to check if it exists before accessing it. Fixes: #1345 --- mock/py/mockbuild/file_downloader.py | 6 +++--- .../release-notes-next/FileDownloader-original_name.bugfix | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 releng/release-notes-next/FileDownloader-original_name.bugfix diff --git a/mock/py/mockbuild/file_downloader.py b/mock/py/mockbuild/file_downloader.py index d4001757e..6506b6d8d 100644 --- a/mock/py/mockbuild/file_downloader.py +++ b/mock/py/mockbuild/file_downloader.py @@ -80,9 +80,9 @@ def _get_inner(cls, url): @classmethod def original_name(cls, localname): """ Get the URL from the local name """ - if not cls.backmap: - return localname - return cls.backmap.get(localname, localname) + if getattr(cls, 'backmap', None): + return cls.backmap.get(localname, localname) + return localname @classmethod def cleanup(cls): diff --git a/releng/release-notes-next/FileDownloader-original_name.bugfix b/releng/release-notes-next/FileDownloader-original_name.bugfix new file mode 100644 index 000000000..6ad6468ad --- /dev/null +++ b/releng/release-notes-next/FileDownloader-original_name.bugfix @@ -0,0 +1,5 @@ +When a `mock --chain --recurse` fails to built at least one package, it is +unable to print a list of failed packages and displays `AttributeError: type +object 'FileDownloader' has no attribute 'backmap'` instead. The `original_name` +method of `FileDownloader` class has been fixed, and the chain build results +displayed as expected ([issue#1345][]). \ No newline at end of file