Files
llvm-project/lldb/test/API/python_api/filespec/TestFileSpecAPI.py
Jonas Devlieghere cf784ac314 [lldb] Support comparing FileSpec against Python strings (#190690)
We got a bug report where someone was iterating over the modules and
wanted to verify that the module name was empty and noticed it didn't
trigger.

```
for module in target.module_iter():
  if module.file is None or module.file == "":
    # Do something
```

My initial hypothesis was that we were somehow skipping modules, but
upon further investigation, it was the string comparison that was the
culprit. The reporter (reasonably) expected the `file` property to
return a string, but in reality it returns a SBFileSpec.

This could be avoided by explicitly comparing with an empty FileSpec,
but that seems needlessly tedious.

```
for module in target.module_iter():
  if module.file is None or module.file == lldb.SBFileSpec(""):
    # Do something
```

Instead, add support for comparing a SBFileSpec against a string.

rdar://174166420
2026-04-07 17:28:11 +01:00

1.1 KiB