Skip to content

Commit acf9752

Browse files
committed
fix: address backwards compatibility warnings failing presubmits
1 parent 61198b8 commit acf9752

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

google/api_core/retry/retry_streaming_async.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,14 @@ async def retry_target_stream(
160160
# bare except catches any exception passed to `athrow`
161161
if target_is_generator:
162162
# delegate error handling to target_iterator
163-
await cast(AsyncGenerator["_Y", None], target_iterator).athrow(
164-
*sys.exc_info()
165-
)
163+
164+
# TODO: Remove this conditional once the minimum supported Python version is 3.11
165+
if sys.version_info[:3] >= (3, 11, 0):
166+
await cast(AsyncGenerator["_Y", None], target_iterator).athrow(
167+
sys.exception())
168+
else:
169+
await cast(AsyncGenerator["_Y", None], target_iterator).athrow(
170+
*sys.exc_info())
166171
else:
167172
raise
168173
return

tests/asyncio/retry/test_retry_streaming_async.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ async def test___call___generator_cancellations(self):
201201
"""
202202
# test without cancel as retryable
203203
retry_ = retry_streaming_async.AsyncStreamingRetry()
204-
utcnow = datetime.datetime.utcnow()
204+
utcnow = datetime.datetime.now(datetime.timezone.utc)
205205
mock.patch("google.api_core.datetime_helpers.utcnow", return_value=utcnow)
206206
generator = await retry_(self._generator_mock)(sleep_time=0.2)
207207
assert await generator.__anext__() == 0

0 commit comments

Comments
 (0)