This is an automated email from the ASF dual-hosted git repository.

tlopex pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git


The following commit(s) were added to refs/heads/main by this push:
     new 93e28d1126 [BugFix][TVMScript] Fix invalid f-string format spec 
causing TypeError on Python 3.14 (#19362)
93e28d1126 is described below

commit 93e28d1126d41158e440fc42db427e7358f30f44
Author: Soowon Jeong <[email protected]>
AuthorDate: Tue Apr 7 03:49:23 2026 +0900

    [BugFix][TVMScript] Fix invalid f-string format spec causing TypeError on 
Python 3.14 (#19362)
    
    ## Problem
    
    On Python 3.14, any use of TVMScript raises a `TypeError` before the
    module body is even parsed:
    
    ```
    TypeError: unsupported format string passed to type.__format__
    ```
    
    The traceback points to
    `python/tvm/script/parser/core/diagnostics.py:120`:
    
    ```python
    raise TypeError(f"Source for {obj:!r} not found")
    ```
    
    ## Root Cause
    
    `{obj:!r}` is an invalid f-string expression. The `:` introduces a
    `format_spec`, so `!r` is passed to `type.__format__` as a format string
    — which it does not support.
    
    The intended syntax for a `repr()` conversion is `{obj!r}` (no colon).
    
    Python 3.14 re-implemented f-string parsing under [PEP
    701](https://peps.python.org/pep-0701/) and now strictly validates
    format specs, surfacing this latent bug. Python 3.10–3.13 silently
    passed the invalid spec to `__format__` and happened not to raise in
    most code paths, so the bug went unnoticed.
    
    ## Fix
    
    ```diff
    - raise TypeError(f"Source for {obj:!r} not found")
    + raise TypeError(f"Source for {obj!r} not found")
    ```
    
    One character change. Valid across all Python versions >= 3.6.
    
    ## Testing
    
    Verified on Python 3.14.2 (darwin/arm64):
    
    - TVMScript `ir_module` + `prim_func` parses and compiles correctly
    after the fix
    - Full TVMScript test suite: **628 passed, 1 xfailed** (the 1 failure in
    `test_tvmscript_roundtrip.py::test_roundtrip[relax_symbolic_size_var]`
    is pre-existing and unrelated to this change)
---
 python/tvm/script/parser/core/diagnostics.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/python/tvm/script/parser/core/diagnostics.py 
b/python/tvm/script/parser/core/diagnostics.py
index 4e5ca08aae..4a6b2574c6 100644
--- a/python/tvm/script/parser/core/diagnostics.py
+++ b/python/tvm/script/parser/core/diagnostics.py
@@ -117,7 +117,7 @@ def _patched_inspect_getfile(obj):
         if inspect.isfunction(member):
             if obj.__qualname__ + "." + member.__name__ == member.__qualname__:
                 return inspect.getfile(member)
-    raise TypeError(f"Source for {obj:!r} not found")
+    raise TypeError(f"Source for {obj!r} not found")
 
 
 def findsource(obj):

Reply via email to