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

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


The following commit(s) were added to refs/heads/main by this push:
     new 4962b353d9e Fix iterating through `ObjectStoragePath` (#57156)
4962b353d9e is described below

commit 4962b353d9e8d56a037ed37af4d818aea83d3cd5
Author: Mikhail Ilchenko <[email protected]>
AuthorDate: Mon Oct 27 00:19:54 2025 +0400

    Fix iterating through `ObjectStoragePath` (#57156)
---
 task-sdk/src/airflow/sdk/io/path.py     | 5 +++++
 task-sdk/tests/task_sdk/io/test_path.py | 9 +++++++++
 2 files changed, 14 insertions(+)

diff --git a/task-sdk/src/airflow/sdk/io/path.py 
b/task-sdk/src/airflow/sdk/io/path.py
index 5b66e09d110..611dfe2c8df 100644
--- a/task-sdk/src/airflow/sdk/io/path.py
+++ b/task-sdk/src/airflow/sdk/io/path.py
@@ -60,6 +60,11 @@ class _TrackingFileWrapper:
 
         return wrapper
 
+    # We need to explicitly implement `__iter__`
+    # because otherwise python iteration logic could use `__getitem__`
+    def __iter__(self):
+        return iter(self._obj)
+
     def __getitem__(self, key):
         # Intercept item access
         return self._obj[key]
diff --git a/task-sdk/tests/task_sdk/io/test_path.py 
b/task-sdk/tests/task_sdk/io/test_path.py
index 78c75cebddf..99a51366494 100644
--- a/task-sdk/tests/task_sdk/io/test_path.py
+++ b/task-sdk/tests/task_sdk/io/test_path.py
@@ -215,6 +215,15 @@ class TestLocalPath:
         assert o.open("rb").read() == b"foo"
         o.unlink()
 
+    def test_read_line_by_line(self, target):
+        o = ObjectStoragePath(f"file://{target}")
+        with o.open("wb") as f:
+            f.write(b"foo\nbar\n")
+        with o.open("rb") as f:
+            lines = list(f)
+        assert lines == [b"foo\n", b"bar\n"]
+        o.unlink()
+
     def test_stat(self, target):
         o = ObjectStoragePath(f"file://{target}")
         assert o.stat().st_size == 0

Reply via email to