[all-commits] [llvm/llvm-project] 42b67e: [lit] Don't crash in _write_message when getsource...

David Young via All-commits all-commits at lists.llvm.org
Tue Jul 14 12:13:43 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 42b67e529c59b77c6dfac9cc5d2b263e752851f6
      https://github.com/llvm/llvm-project/commit/42b67e529c59b77c6dfac9cc5d2b263e752851f6
  Author: David Young <davidayoung at meta.com>
  Date:   2026-07-14 (Tue, 14 Jul 2026)

  Changed paths:
    M llvm/utils/lit/lit/LitConfig.py
    A llvm/utils/lit/tests/unit/LitConfig.py

  Log Message:
  -----------
  [lit] Don't crash in _write_message when getsourcefile() returns None (#206957)

LitConfig._write_message currently derives the file to report a
note()/warning()/ error() against with:

    file = os.path.abspath(inspect.getsourcefile(f))

inspect.getsourcefile(f) returns None when the calling frame's source is
not on disk and not in linecache -- for example when lit is packaged
into a zip archive, or when a config is exec'd from a synthetic
filename. In that case os.path.abspath(None) raises TypeError: expected
str, bytes or os.PathLike object, not NoneType, which turns an
informational diagnostic into a fatal config-parse crash.

Fall back to inspect.getfile(f), which returns the frame's co_filename
and is always a str, so the diagnostic is emitted (tagged with
co_filename) instead of crashing. Since all tests normally pass
currently on build bots, this new code should never trigger and only
works as a backup in the case I'm running into on a different test infra
running lit tests.

Add a lit unit test covering the None case.

Assisted with- claude



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list