Skip to content

Return raw XID when resource table is absent - #297

Open
barlowa124 wants to merge 1 commit into
python-xlib:masterfrom
barlowa124:get-resource-class-fallback-281
Open

barlowa124 wants to merge 1 commit into
python-xlib:masterfrom
barlowa124:get-resource-class-fallback-281

Conversation

@barlowa124

Copy link
Copy Markdown

Summary

Fixes #281.

protocol.display.Display.get_resource_class reads self.resource_classes, an attribute populated only by the Xlib.display.Display wrapper when the xobject layer loads. A display opened at the protocol level, as examples/draw-proto.py does with display.Display() from Xlib.protocol, has no such table. Parsing any reply containing a resource-typed field then failed with AttributeError: 'Display' object has no attribute 'resource_classes', which is the traceback in the issue.

The lookup now falls back to an empty table and returns the caller's default. The reply decoder already treats a missing class as "return the raw XID", so protocol-level users get the XID integer back rather than a crash, matching what the test suite's DummyDisplay has always done.

New test/test_protocol_display.py covers the bare-display fallback and the resource-field decode path that raised in the report, plus normal lookups on a populated table.

…lass

Display.get_resource_class reads self.resource_classes, which is only
populated by the Xlib.display.Display wrapper (xobject layer). Displays
opened at the protocol level, as in examples/draw-proto.py, have no such
table, so parsing any reply containing a resource-typed field failed
with AttributeError: 'Display' object has no attribute 'resource_classes'.

Fall back to an empty table so the lookup returns the caller's default,
which the reply decoder already handles by passing the raw XID through.

Fixes python-xlib#281
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.

draw-proto.py example returns AttributeError on Ubuntu 22.04 python-xlib v.033 installed from source

1 participant