From 8ac30732edf2a09c2d5abfe52c0008ea5e8e495d Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Thu, 30 Oct 2025 12:09:26 +0100 Subject: [PATCH 1/2] fix: Avoid return from finally: block MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 ```` --- posthog/consumer.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/posthog/consumer.py b/posthog/consumer.py index cbb77fd1..021d4343 100644 --- a/posthog/consumer.py +++ b/posthog/consumer.py @@ -84,12 +84,16 @@ def upload(self): self.log.error("error uploading: %s", e) success = False if self.on_error: - self.on_error(e, batch) + try: + self.on_error(e, batch) + except Exception as e: + self.log.error("on_error handler failed: %s", e) finally: # mark items as acknowledged from queue for item in batch: self.queue.task_done() - return success + + return success def next(self): """Return the next batch of items to upload.""" From ae32dfccbb5946a5a0e3a5a7328476f7169a0052 Mon Sep 17 00:00:00 2001 From: Paul D'Ambra Date: Wed, 7 Jan 2026 22:47:36 +0000 Subject: [PATCH 2/2] add versioning info --- CHANGELOG.md | 4 ++++ posthog/version.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index adf52b5f..272f4174 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 7.5.1 - 2026-01-07 + +fix: avoid return from finally block to fix Python 3.14 SyntaxWarning (#361)[https://github.com/PostHog/posthog-python/pull/361] - thanks @jodal + # 7.5.0 - 2026-01-06 feat: Capture Langchain, OpenAI and Anthropic errors as exceptions (if exception autocapture is enabled) diff --git a/posthog/version.py b/posthog/version.py index 337cf760..353acdce 100644 --- a/posthog/version.py +++ b/posthog/version.py @@ -1,4 +1,4 @@ -VERSION = "7.5.0" +VERSION = "7.5.1" if __name__ == "__main__": print(VERSION, end="") # noqa: T201