diff mbox series

[wic,v4,5/6] bb/utils: import errno so mkdirhier's OSError handler works

Message ID 20260706222904.664863-6-twoerner@gmail.com
State New
Headers show
Series tests: standalone test-suite framework plus the first unit test | expand

Commit Message

Trevor Woerner July 6, 2026, 10:29 p.m. UTC
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 <twoerner@gmail.com>
---
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 mbox series

Patch

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