PyNUT: restore socket cleanup in disconnect() - #3627
Open
user01010111 wants to merge 3 commits into
Open
Conversation
Remove the unmangled hasattr() check which prevented cleanup of a retained client's socket. The class-level None default already makes direct access safe before a connection has been assigned. Preserve the existing best-effort LOGOUT, close and reference cleanup behavior. Exercise it in the existing Python test script and make check, including failure injection, partial initialization and a loopback socket. Document the fix in NEWS.adoc. Closes: networkupstools#3619 AI assistance: OpenAI Codex with gpt-6-astra (x-high reasoning). The human contributor remains responsible for reviewing and submitting the change. Signed-off-by: user01010111 <12504630+user01010111@users.noreply.github.com>
networkupstools#3627] Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
|
A ZIP file with standard source tarball and another tarball with pre-built docs for commit 7178b2c is temporarily available: NUT-tarballs-PR-3627.zip. |
|
✅ Build nut 2.8.5.5249-master completed (commit 806444fed7 by @user01010111)
|
|
✅ Build nut 2.8.5.5249-master completed (commit 806444fed7 by @user01010111) |
|
✅ Build nut 2.8.5.5251-master completed (commit 5db3642959 by @jimklimov)
|
Member
|
Regarding failed "slowbuild-run/MATRIX_TAG=gnu99-gnu++98-debian11" scenario: same issue as #3628 (comment) UPDATE: I'm on it now |
jimklimov
added a commit
to user01010111/nut
that referenced
this pull request
Sep 9, 2026
…etworkupstools#3627, networkupstools#3628] Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…test` module on some systems [networkupstools#3627] Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
|
✅ Build nut 2.8.5.5266-master completed (commit 0d1ca0a0dc by @jimklimov)
|
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.
Calling
disconnect()on a retainedPyNUTClientleaves its socket open:the literal name passed to
hasattr()does not undergo Python's privatename mangling. Read the existing class attribute directly so the existing
LOGOUT, close and reference cleanup code runs. Its class-level
Nonedefault covers deferred and partial initialization; send and close errors
remain independently suppressed.
Add 12 regression tests to the existing Python test script and run them
from
make check, without requiring an external NUT server. They covercleanup order, repeat calls, explicit destructor calls, subclasses,
connection/authentication failures, send/close failures, and real loopback
transmission and closure. The same script continues to run the existing
server integration tests. Add a release-note entry; no public API,
dependency, version or hardware-support change is intended.
Closes: #3619
Validation:
ab687a162ad99d2c687c48f02b498845f69c4d91, including absent LOGOUT/closeevents and the retained open socket. All 12 pass with the fix.
3.9.25, 3.10.21, 3.11.16, 3.12.14, 3.13.15 and 3.14.7 pass.
macOS ARM64: Python 3.9.6 and 3.14.7 pass.
cipher-fallback cleanup tests pass on Linux and macOS.
upsdanddummy-ups: retained plain/TLS clients releasetheir sockets and logged-in sessions after explicit/destructor cleanup;
replacement clients reconnect. The existing Python script passes on
Python 2.6.9 and 3.11.15. The NUT Python integration harness passes
4 groups with no failures or skips.
and staged NUT install pass. Source-package installation and its installed
tests also pass on Python 2.6.9 using setuptools 36.8.0.
make check(including 12 Automake tests),make stylecheck,make spellcheckandmake distcheck-lightpass.The final distribution check generates real man pages and HTML and
exercises the extracted archive's build, tests, install/uninstall and
cleanup. The four changed source files match that archive exactly.
No physical UPS hardware was available for testing. Validation covered
deterministic socket tests, real localhost TCP/TLS connections, and locally
built
upsdwith simulateddummy-upsdevices.Physical UPS models, firmware versions, and hardware combinations were
not tested.
Windows was not executed. Python 2.6 uses the plain socket path because
this module disables SSL on runtimes without
ssl.create_default_context.Relevant checklist:
AI assistance: OpenAI Codex with gpt-6-astra (x-high reasoning).
The human contributor remains responsible for reviewing and submitting
the change.