Skip to content

Commit f9c2959

Browse files
jodalpauldambra
andauthored
fix: avoid return from finally block to fix Python 3.14 SyntaxWarning (#361)
* fix: Avoid return from finally: block This fixes a SyntaxWarning on Python 3.14. ``` ❯ uvx --no-cache --python 3.14.0 --with posthog==6.7.11 python -c "import posthog" Installed 11 packages in 5ms .../lib/python3.14/site-packages/posthog/consumer.py:92: SyntaxWarning: 'return' in a 'finally' block return success ```` * add versioning info --------- Co-authored-by: Paul D'Ambra <[email protected]>
1 parent 2b3eb67 commit f9c2959

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 7.5.1 - 2026-01-07
2+
3+
fix: avoid return from finally block to fix Python 3.14 SyntaxWarning (#361)[https://github.com/PostHog/posthog-python/pull/361] - thanks @jodal
4+
15
# 7.5.0 - 2026-01-06
26

37
feat: Capture Langchain, OpenAI and Anthropic errors as exceptions (if exception autocapture is enabled)

posthog/consumer.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,16 @@ def upload(self):
8484
self.log.error("error uploading: %s", e)
8585
success = False
8686
if self.on_error:
87-
self.on_error(e, batch)
87+
try:
88+
self.on_error(e, batch)
89+
except Exception as e:
90+
self.log.error("on_error handler failed: %s", e)
8891
finally:
8992
# mark items as acknowledged from queue
9093
for item in batch:
9194
self.queue.task_done()
92-
return success
95+
96+
return success
9397

9498
def next(self):
9599
"""Return the next batch of items to upload."""

posthog/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION = "7.5.0"
1+
VERSION = "7.5.1"
22

33
if __name__ == "__main__":
44
print(VERSION, end="") # noqa: T201

0 commit comments

Comments
 (0)