Skip to content

gh-135683: Ensure that WatchedFileHandler calls handleError on exceptions. - #145246

Closed
vsajip wants to merge 2 commits into
python:mainfrom
vsajip:fix-135683
Closed

vsajip wants to merge 2 commits into
python:mainfrom
vsajip:fix-135683

Conversation

@vsajip

@vsajip vsajip commented Feb 26, 2026 •

Copy link
Copy Markdown
Member

@vsajip vsajip self-assigned this Feb 26, 2026
@vsajip vsajip added the type-bug An unexpected behavior, bug, or error label Feb 26, 2026
@vsajip vsajip added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Feb 28, 2026
@bedevere-bot

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @vsajip for commit 33a9869 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F145246%2Fmerge

If you want to schedule another build, you need to add the 🔨 test-with-buildbots label again.

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Feb 28, 2026
@vsajip
vsajip requested a review from picnixz March 9, 2026 14:19
Comment thread Lib/logging/__init__.py
Comment on lines +1260 to +1263
try:
self.stream = self._open()
except Exception:
self.handleError(record)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very silly but I wonder whether a possible AttributeErrorn raised when _open() is missing should be handled or not. Maybe we should only catch the exception when doing:

do_open = self._open
try:
    stream = do_open()
except Exception:
    self.handleError(record)
else:
    self._stream = stream

Or do you think it makes sense to let exceptions happening when setting the field and accessing _open() being handled normally?

@github-actions

github-actions Bot commented May 7, 2026

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label May 7, 2026
@serhiy-storchaka

Copy link
Copy Markdown
Member

Ah, oops — I did not notice this PR when I created the almost identical #154542. Well, at least this confirms the approach is correct.

One thing to note: #154542 does not call FileHandler.emit() if reopening failed. Otherwise the same error is handled twice.

@github-actions github-actions Bot removed the stale Stale PR or inactive for long period of time. label Jul 30, 2026
@serhiy-storchaka serhiy-storchaka added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes and removed needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Sep 19, 2026
@serhiy-storchaka

Copy link
Copy Markdown
Member

Merged #154542 which is stricter and has @vsajip's approval. Added @vsajip as co-author.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting core review skip news type-bug An unexpected behavior, bug, or error

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants