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

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


The following commit(s) were added to refs/heads/main by this push:
     new 727106f7ff GH-48608: [Python] Fix interpolate actual values in 
Message.__repr__ f-string (#48656)
727106f7ff is described below

commit 727106f7ff65065298e1e79071fed2a408b4b4d6
Author: Aokizy <[email protected]>
AuthorDate: Sun Jan 4 23:27:33 2026 +0800

    GH-48608: [Python] Fix interpolate actual values in Message.__repr__ 
f-string (#48656)
    
    ### Rationale for this change
    `Message.__repr__` showed format placeholders (`{self.type}`) instead of 
actual values.
    
    ### What changes are included in this PR?
    Add missing `f` prefix to f-string in `Message.__repr__` (pyarrow/lib.pxi).
    
    ### Are these changes tested?
    Yes: added test verifying string representation shows actual values.
    
    ### Are there any user-facing changes?
    Yes (bug fix): `str(message)` now shows values like `type: RecordBatch` 
instead of placeholders.
    related to issue #48608
    * GitHub Issue: #48608
    
    Authored-by: aokizy <[email protected]>
    Signed-off-by: Rok Mihevc <[email protected]>
---
 python/pyarrow/ipc.pxi           |  2 +-
 python/pyarrow/tests/test_ipc.py | 12 ++++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/python/pyarrow/ipc.pxi b/python/pyarrow/ipc.pxi
index 2347b3c7a3..6477579af2 100644
--- a/python/pyarrow/ipc.pxi
+++ b/python/pyarrow/ipc.pxi
@@ -479,7 +479,7 @@ cdef class Message(_Weakrefable):
         body = self.body
         body_len = 0 if body is None else body.size
 
-        return """pyarrow.Message
+        return f"""pyarrow.Message
 type: {self.type}
 metadata length: {metadata_len}
 body length: {body_len}"""
diff --git a/python/pyarrow/tests/test_ipc.py b/python/pyarrow/tests/test_ipc.py
index b4db9cd087..6813ed7772 100644
--- a/python/pyarrow/tests/test_ipc.py
+++ b/python/pyarrow/tests/test_ipc.py
@@ -779,6 +779,18 @@ def test_message_serialize_read_message(example_messages):
         pa.ipc.read_message(reader)
 
 
+def test_message_repr_shows_actual_values(example_messages):
+    _, messages = example_messages
+
+    for msg in messages:
+        s = str(msg)
+
+        assert '{self.type}' not in s
+        assert '{metadata_len}' not in s
+        assert '{body_len}' not in s
+        assert f'type: {msg.type}' in s
+
+
 @pytest.mark.gzip
 def test_message_read_from_compressed(example_messages):
     # Part of ARROW-5910

Reply via email to