fix(utils): #3852 ensure sarge Capture.flush exists on Py 3.13+#3980
Draft
jstvz wants to merge 2 commits into
Draft
fix(utils): #3852 ensure sarge Capture.flush exists on Py 3.13+#3980jstvz wants to merge 2 commits into
jstvz wants to merge 2 commits into
Conversation
sarge==0.1.7.post1 ships without Capture.flush, and Python 3.13+ logging calls flush() during interpreter shutdown after refresh_oauth_token, which surfaces a cosmetic AttributeError. Add a regression test that asserts sarge.Capture exposes a callable, no-op flush() after importing cumulusci.utils. Currently failing: the fix lands in the next commit. Refs #3852
pyproject.toml pins ``sarge`` with no version constraint, so the installed version is 0.1.7.post1, whose Capture class lacks a flush() method. The upstream fix is unreleased on sarge's master branch. Python 3.13+ interpreter-shutdown logging path calls flush() on captured streams that CumulusCI hands to logging handlers via sarge.Command(stdout=Capture(...)). After refresh_oauth_token (which calls sfdx_info → sfdx() → sarge.Command with Capture) the shutdown logger therefore emits a cosmetic ``AttributeError: 'Capture' object has no attribute 'flush'``. Functionally a no-op, but noisy and confusing. Install an idempotent shim at the cumulusci.utils import site that adds Capture.flush = lambda self: None only if sarge does not already provide flush(). When sarge eventually ships its own flush(), the guard skips the patch automatically. Refs #3852
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #3852.
sarge.Capturelost itsflush()method under newer Python/pipe semantics, surfacing as a noisyAttributeErroron shutdown when CumulusCI captures subprocess output. This adds a one-shot monkey-patch atcumulusci/utils/__init__.pyimport time: ifsarge.Capturehas noflushattribute, install a no-opflush()so callers that probe the attribute do not crash. No functional change to sarge behavior.Test plan
cumulusci/utils/tests/test_sarge_patch.py::test_sarge_capture_has_flush_after_importpasses.cumulusci/tests/triage/test_issue_3852.pyremoved in the GREEN commit; test now passes.uv run pytest cumulusci/utils/tests/ -qclean.Provenance
Reproduced and characterized in the v5 triage evidence pack (PR #3979). See
docs/triage/v5/repro-results.md(### #3852) for the full narrative.