Skip to content

Resolve GitHub code quality findings and clarify descriptor ownership - #16

Merged
rjcloudsigma merged 1 commit into
masterfrom
maintenance/code-quality-findings
Oct 31, 2026
Merged

rjcloudsigma merged 1 commit into
masterfrom
maintenance/code-quality-findings

Conversation

@rjcloudsigma

@rjcloudsigma rjcloudsigma commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

GitHub Code Quality reports 17 open findings on master. This change addresses every finding while preserving the Python 2.7 / Python 3.6+ API contract and existing runtime behavior.

Findings Review and change
#22, #23, #24 — file not always closed The existing helper already closed descriptors if flag setup failed, but obscured ownership from the analyzer. Keep descriptor acquisition and failure cleanup in the same scope, with an explicit ownership return from _open_at. Add three regression tests covering root, native/procfs open and duplicate-descriptor cleanup; verify the root remains usable after duplicate setup failure.
#19, #20, #21 — empty except Explain the intentional numeric/sequence encoding fallbacks and best-effort destructor cleanup. Preserve exception behavior.
#13, #14, #15, #16, #17, #18 — mixed returns Return None explicitly for skipped descriptor writes and unsuccessful tree/group/VM lookups. Preserve existing results.
#25, #26 — imprecise assertions Use precise boolean identity assertions while still invoking ==. Using assertNotEqual here could bypass the custom equality method on Python 2.
#27, #28 — unused imports Remove unused DictOrFlagFile and BaseFileInterface imports.
#12 — implicit string concatenation in a list Name the intentionally concatenated child program before passing it to Popen; retain exactly the same program and stdin gate.

Validation: all 137 tests pass locally on Python 3.12; source and universal-wheel builds pass strict twine check; git diff --check passes. Independent code review found no actionable defects. All 16 GitHub checks pass, including Python 2.7 and 3.6–3.15, distribution installation, Linux cgroup integration, CodeQL, and Code Quality. Passing CI, passing Code Quality analysis.

No finding has been dismissed or suppressed. No version bump or release is included.

Comment thread cgroupspy/test/test_v2.py

def test_open_at_closes_when_cloexec_setup_fails(self):
for native_openat in (False, True):
descriptor = os.open(self.root_path, os.O_RDONLY)
Comment thread cgroupspy/test/test_v2.py
with mock.patch.object(v2.os, 'supports_dir_fd', supported, create=True):
with mock.patch.object(v2, '_set_cloexec', side_effect=OSError(errno.EIO, 'Flag failure')):
with self.assertRaises(OSError):
v2._open_at(123, 'cgroup.procs', os.O_RDONLY)
Comment thread cgroupspy/test/test_v2.py

with mock.patch.object(v2, '_set_cloexec', side_effect=fail_cloexec):
with self.assertRaises(OSError):
tree._directory(())
@rjcloudsigma
rjcloudsigma merged commit 729decc into master Oct 31, 2026
16 checks passed
@rjcloudsigma
rjcloudsigma deleted the maintenance/code-quality-findings branch October 31, 2026 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant