All of lore.kernel.org
 help / color / mirror / Atom feed
From: Trevor Woerner <twoerner@gmail.com>
To: yocto-patches@lists.yoctoproject.org
Subject: [wic][PATCH v4 5/6] bb/utils: import errno so mkdirhier's OSError handler works
Date: Mon,  6 Jul 2026 18:29:03 -0400	[thread overview]
Message-ID: <20260706222904.664863-6-twoerner@gmail.com> (raw)
In-Reply-To: <20260706222904.664863-1-twoerner@gmail.com>

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 --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



  parent reply	other threads:[~2026-07-06 22:29 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-06 22:28 [wic][PATCH v4 0/6] tests: standalone test-suite framework plus the first unit test Trevor Woerner
2026-07-06 22:28 ` [wic][PATCH v4 1/6] tests: add the standalone unit-test suite skeleton Trevor Woerner
2026-07-06 22:29 ` [wic][PATCH v4 2/6] tests: add conftest with a wic-import preflight and session banner Trevor Woerner
2026-07-06 22:29 ` [wic][PATCH v4 3/6] tests: add optional coverage reporting Trevor Woerner
2026-07-06 22:29 ` [wic][PATCH v4 4/6] add ruff linting Trevor Woerner
2026-07-06 22:29 ` Trevor Woerner [this message]
2026-07-06 22:29 ` [wic][PATCH v4 6/6] tests/unit/test_bb_utils: cover mkdirhier() Trevor Woerner
2026-07-08 14:27 ` [yocto-patches] [wic][PATCH v4 0/6] tests: standalone test-suite framework plus the first unit test Paul Barker
2026-07-09  3:50 ` Trevor Woerner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260706222904.664863-6-twoerner@gmail.com \
    --to=twoerner@gmail.com \
    --cc=yocto-patches@lists.yoctoproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.