[wic][PATCH v4 5/6] bb/utils: import errno so mkdirhier's OSError handler works
Trevor Woerner <[email protected]> Mon, 6 Jul 2026 18:29:03 -0400
| Newsgroups | org.yoctoproject.lists.yocto-patches |
|---|---|
| Message-ID | <[email protected]> |
mkdirhier() calls os.makedirs(directory, exist_ok=True) and, if that
still raises OSError, re-checks the error before deciding what to do:
except OSError as e:
if e.errno != errno.EEXIST or not os.path.isdir(directory):
raise e
but the module never imports errno. The reference to errno.EEXIST is
only evaluated when os.makedirs() actually raises, so the defect stays
hidden on every ordinary call. The moment a real OSError occurs -- a
parent component that is a file, a permission error, anything -- the
handler itself raises NameError: name 'errno' is not defined, masking
the original error with a misleading one.
Import errno so the handler behaves as intended: it re-raises every real
error, while tolerating only an EEXIST whose path is in fact already a
directory.
AI-Generated: codex/claude-opus 4.8 (xhigh)
Signed-off-by: Trevor Woerner <[email protected]>
---
changes in v4:
- new commit: the errno import fix now lands on its own, before the
test that exercises it. In v2 and v3 it was folded into the
test_bb_utils commit.
---
src/wic/bb/utils.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/wic/bb/utils.py b/src/wic/bb/utils.py
index 3750056ba563..0b40dd0c1d59 100644
--- a/src/wic/bb/utils.py
+++ b/src/wic/bb/utils.py
@@ -1,6 +1,7 @@
"""
Minimal subset of BitBake's bb.utils used by standalone wic.
"""
+import errno
import os
# from bitbake/lib/bb/utils.py
--
2.50.0.173.g8b6f19ccfc3a