You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "paleolimbot (via GitHub)" <gi...@apache.org> on 2023/07/19 13:52:19 UTC

[GitHub] [arrow-nanoarrow] paleolimbot opened a new pull request, #262: fix(python): Ensure generator does not raise `StopIteration`

paleolimbot opened a new pull request, #262:
URL: https://github.com/apache/arrow-nanoarrow/pull/262

   As noted in #258, the Python tests are failing! I'm not sure the details of why this started now, but `StopIteration` was being raised in a generator which should just return instead.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-nanoarrow] paleolimbot merged pull request #262: fix(python): Ensure generator does not raise `StopIteration`

Posted by "paleolimbot (via GitHub)" <gi...@apache.org>.
paleolimbot merged PR #262:
URL: https://github.com/apache/arrow-nanoarrow/pull/262


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-nanoarrow] paleolimbot commented on a diff in pull request #262: fix(python): Ensure generator does not raise `StopIteration`

Posted by "paleolimbot (via GitHub)" <gi...@apache.org>.
paleolimbot commented on code in PR #262:
URL: https://github.com/apache/arrow-nanoarrow/pull/262#discussion_r1268819408


##########
python/src/nanoarrow/_lib.pyx:
##########
@@ -894,8 +894,11 @@ cdef class ArrayStream:
             return array
 
     def __iter__(self):
-        while True:
-            yield self.get_next()
+        try:

Review Comment:
   Thanks! I just looked it up and my head is about to explode but it does sound cleaner/the thing we should be doing 🤯 



##########
python/src/nanoarrow/_lib.pyx:
##########
@@ -894,8 +894,11 @@ cdef class ArrayStream:
             return array
 
     def __iter__(self):
-        while True:
-            yield self.get_next()
+        try:

Review Comment:
   Thanks! I just looked it up and my head is about to explode but it does sound cleaner/the thing we should be doing 🤯 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-nanoarrow] jorisvandenbossche commented on a diff in pull request #262: fix(python): Ensure generator does not raise `StopIteration`

Posted by "jorisvandenbossche (via GitHub)" <gi...@apache.org>.
jorisvandenbossche commented on code in PR #262:
URL: https://github.com/apache/arrow-nanoarrow/pull/262#discussion_r1269088588


##########
python/src/nanoarrow/_lib.pyx:
##########
@@ -894,8 +894,11 @@ cdef class ArrayStream:
             return array
 
     def __iter__(self):
-        while True:
-            yield self.get_next()
+        try:

Review Comment:
   I was also refreshing my Python knowledge on this, and so it's actually in the `__next__` method that a StopIteration needs to be raised, not in `__iter__`
   
   So another way to implement this would be:
   
   ```
   def __iter__(self):
       return self
   
   def __next__(self):
       return self.get_next()
   ```
   
   (but the current one works fine as well)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-nanoarrow] WillAyd commented on a diff in pull request #262: fix(python): Ensure generator does not raise `StopIteration`

Posted by "WillAyd (via GitHub)" <gi...@apache.org>.
WillAyd commented on code in PR #262:
URL: https://github.com/apache/arrow-nanoarrow/pull/262#discussion_r1268448773


##########
python/src/nanoarrow/_lib.pyx:
##########
@@ -894,8 +894,11 @@ cdef class ArrayStream:
             return array
 
     def __iter__(self):
-        while True:
-            yield self.get_next()
+        try:

Review Comment:
   I _think_ this is also the use case for `yield from` in Python



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org