diff mbox series

[wic,1/4] oe/path: fix bare `false` NameError in __realpath's isdir guard

Message ID 20260709205227.3470712-2-twoerner@gmail.com
State New
Headers show
Series oe/path: three fixes plus unit coverage | expand

Commit Message

Trevor Woerner July 9, 2026, 8:52 p.m. UTC
__realpath() finishes by deciding whether the resolved path is a
directory, tolerating any error from the stat:

    try:
        is_dir = os.path.isdir(file)
    except:
        is_dir = false

but `false` is not a Python name -- the intended value is the builtin
False. os.path.isdir() swallows almost everything and simply returns
False for a path it cannot stat, so the except branch is rarely taken;
that is why the typo has stayed hidden. But when isdir() does raise --
for instance an OSError deep in os.stat() on a broken mount -- the
handler that was meant to absorb the error instead raises
NameError: name 'false' is not defined, masking the original failure
with a misleading one.

Use the builtin False so the fallback behaves as intended: a path that
cannot be stat'd is simply reported as not-a-directory.

AI-Generated: codex/claude-opus 4.8 (xhigh)
Signed-off-by: Trevor Woerner <twoerner@gmail.com>
---
 src/wic/oe/path.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/src/wic/oe/path.py b/src/wic/oe/path.py
index 3e95ea0ec923..862edc532ade 100644
--- a/src/wic/oe/path.py
+++ b/src/wic/oe/path.py
@@ -233,7 +233,7 @@  def __realpath(file, root, loop_cnt, assume_dir):
     try:
         is_dir = os.path.isdir(file)
     except:
-        is_dir = false
+        is_dir = False
 
     return (file, is_dir)