[llvm] [llvm-lit] Unhashable TypeError Support (PR #101590)

Paul Kirth via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 1 18:50:08 PDT 2024


================
@@ -767,6 +767,13 @@ def _executeShCmd(cmd, shenv, results, timeoutHelper):
         # echo-appending to a file.
         # FIXME: Standardize on the builtin echo implementation. We can use a
         # temporary file to sidestep blocking pipe write issues.
+
+        # Ensure args[0] is hashable before using it in inproc_builtins
+        if isinstance(args[0], GlobItem):
+            expanded_args = expand_glob(args[0], cmd_shenv.cwd)
----------------
ilovepi wrote:

This isn't a check if it's `Hashable` though, it's just a check if the instance is a `GlobItem`.

Why not just do the expansion at the call site though? `expand_glob()` is already checking if it's a `GlobItem`. It also won't modify `args[0]`, which seems preferable, since `expand_glob_expressions()` goes out of its way not to modify `args[0]`.
```
inproc_builtin = inproc_builtins.get(expand_glob(args[0], cmd_shenv.cwd)[0], None)
```

https://github.com/llvm/llvm-project/pull/101590


More information about the llvm-commits mailing list