Skip to content

Fix ThreadedVNCClientProxy to use bound methods#309

Open
sibson wants to merge 1 commit intomasterfrom
fix/proxy-bound-methods-v2
Open

Fix ThreadedVNCClientProxy to use bound methods#309
sibson wants to merge 1 commit intomasterfrom
fix/proxy-bound-methods-v2

Conversation

@sibson
Copy link
Owner

@sibson sibson commented Mar 8, 2026

Summary

  • Fix TypeError: VNCDoToolClient.captureScreen() missing 1 required positional argument: 'fp' #297: ThreadedVNCClientProxy.__getattr__ was using unbound methods from the VNCDoToolClient class and relying on the Twisted deferred chain to pass the protocol instance as self. This caused TypeError: VNCDoToolClient.captureScreen() missing 1 required positional argument: 'fp' when the chain result diverged from the protocol.
  • Relates to API documentation: self via Deferred #266: Any exception permanently switched the deferred to errback mode, making all subsequent proxy calls fatal. The fix adds a restore_protocol callback via addBoth that always returns the deferred chain to callback mode.
  • Adds unit tests for ThreadedVNCClientProxy (previously untested).

Changes

  1. Use bound methods from self.protocol (the instance) instead of unbound methods from the class
  2. Don't pass protocol as first arg to maybeDeferred — bound methods already have self
  3. Add restore_protocol callback to ensure the deferred chain always recovers after each call

Test plan

  • All 8 new unit tests pass, all existing tests pass
  • Functional test with Xvnc (requires Xvnc)
  • New tests cover:
    • Basic method proxying with bound methods
    • Args/kwargs passed correctly
    • Methods returning Deferreds (like captureScreen)
    • Multiple sequential calls
    • Chain recovery after a failed Deferred
    • Chain recovery after a raised exception
    • Non-callable attribute access
    • Missing attribute raises AttributeError

🤖 Generated with Claude Code

The proxy's __getattr__ was using unbound methods from the VNCDoToolClient
class and relying on the Twisted deferred chain to pass the protocol instance
as self. This caused TypeError when the chain result diverged from the
protocol (e.g. after an error), and made any exception fatal for the proxy
since the deferred would permanently switch to errback mode.

Use bound methods from the protocol instance and restore the deferred chain
after each call so subsequent calls always work.

Fixes #297
Relates to #266

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@pmhahn
Copy link
Collaborator

pmhahn commented Mar 9, 2026

I just a s short look and it looks okay.
I no longer have my test environment with Xvnc myself handy, so couldn't test it also. Maybe I still have it on a different computer.

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.

2 participants